PING: [PATCH] Improve message 'Undefined allocation of 0 bytes'
Arthur O'Dwyer
arthur.j.odwyer at gmail.com
Wed Apr 23 11:18:13 PDT 2014
On Wed, Apr 23, 2014 at 9:54 AM, Daniel Marjamäki
<Daniel.Marjamaki at evidente.se> wrote:
> Jordan Rose wrote:
>>
>> How about "allocation of 0 bytes has unspecified behavior"? It's a bit more wordy,
>> but it also sounds more like something to pay attention to.
>
> [...]
> If you think "unspecified behaviour" is better I will happily change it.
Since the raison d'etre of this patch is that the current warning
message is technically incorrect,
IMHO it would be a mistake to change the message to something that is
*equally* incorrect.
>From N1570 (the publicly available C11 draft standard):
] If the size of the space requested is zero, the behavior is
implementation-defined:
] either a null pointer is returned, or the behavior is as if the size
were some nonzero value,
] except that the returned pointer shall not be used to access an object.
The difference between "unspecified" and "implementation-defined" is
that conforming implementations MUST document their choices re
"implementation-defined" behavior, whereas "unspecified" behavior
might change capriciously even within a single run of the same
program.
Jordan Rose wrote:
>> (I thought about "implementation-defined behavior" as well, but I'm not sure that's strong
>> enough either...people might just assume they know how their own implementation works.
>> Then again, it is documented for many platforms.)
It's documented by *all* conforming C implementations, by definition.
Of course in practice this just means that the vast majority of C
implementations aren't conforming. ;)
–Arthur
More information about the cfe-commits
mailing list