View Issue Details

IDProjectCategoryView StatusLast Update
00006881003.1(2013)/Issue7+TC1System Interfacespublic2019-06-10 08:55
Reportergeoffclare Assigned To 
PrioritynormalSeverityObjectionTypeError
Status ClosedResolutionAccepted 
NameGeoff Clare
OrganizationThe Open Group
User Reference
Sectionrealloc
Page Number1769
Line Number56971
Interp Status---
Final Accepted Text
Summary0000688: realloc(NULL, 0) vs. malloc(0)
DescriptionThe changes to the realloc() page in TC1 have introduced a conflict
between the requirements for realloc(NULL, 0) and malloc(0).

The realloc() page says:

    If ptr is a null pointer, realloc() shall be equivalent to
    malloc() for the specified size.

However, when size is 0 all that is required of malloc() is "either a
null pointer or a unique pointer that can be successfully passed to
free() shall be returned". This does not match the new requirements
for realloc(NULL, 0), where if it returns a null pointer, it must set
errno.

The intention of the realloc() changes was to allow applications to
be able to determine whether the old pointer was freed. Since this
doesn't apply when realloc() is passed a null pointer, I assume
the new requirements should only apply to the non-null case. An
alternative solution would be to change the equivalence statement
to "If ptr is a null pointer [CX]and size is non-zero[/CX], realloc()
shall be equivalent to malloc() for the specified size."
Desired ActionChange:

    A null pointer shall be returned [CX]and errno set to an
    implementation-defined value[/CX].

to:

    A null pointer shall be returned [CX]and, if ptr is not a null
    pointer, errno shall set to an implementation-defined value[/CX].
Tagstc2-2008

Relationships

related to 0000400 Closedajosey 1003.1(2008)/Issue 7 realloc wording conflicts with C99 
related to 0000526 Closedajosey 1003.1(2008)/Issue 7 Adopt C99 wording for zero size calloc(), malloc() et al. 
related to 0000374 Closedajosey 1003.1(2008)/Issue 7 malloc(0) and realloc(p,0) must not change errno on success 

Activities

There are no notes attached to this issue.

Issue History

Date Modified Username Field Change
2013-05-03 16:08 geoffclare New Issue
2013-05-03 16:08 geoffclare Name => Geoff Clare
2013-05-03 16:08 geoffclare Organization => The Open Group
2013-05-03 16:08 geoffclare Section => realloc
2013-05-03 16:08 geoffclare Page Number => 1769
2013-05-03 16:08 geoffclare Line Number => 56971
2013-05-03 16:08 geoffclare Interp Status => ---
2013-05-09 15:56 eblake Relationship added related to 0000400
2013-05-09 15:57 eblake Relationship added parent of 0000526
2013-05-09 15:57 eblake Relationship added parent of 0000374
2013-05-09 15:58 Don Cragun Status New => Resolved
2013-05-09 15:58 Don Cragun Resolution Open => Accepted
2013-05-09 15:58 Don Cragun Tag Attached: tc2-2008
2013-05-09 16:23 eblake Relationship deleted parent of 0000526
2013-05-09 16:23 eblake Relationship added related to 0000526
2013-05-09 16:23 eblake Relationship deleted parent of 0000374
2013-05-09 16:23 eblake Relationship added related to 0000374
2019-06-10 08:55 agadmin Status Resolved => Closed