This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: memset zero bytes at NULL - isolate-erroneous-paths


* Jonathan Wakely:

> On 17 November 2013 18:25, Dominic News wrote:
>> In the following code (from xorg-server)
>>
>>     if (a == 0)
>>         addr = 0;
>>     (...)
>>     memset(addr, '\0', a);
>>
>> the path for a==0 is turned into a trap by -fisolate-erroneous-paths. (Is
>> calling memset like this undefined behaviour?)
>
> Yes. 7.23.1 in the C standard says that even with a zero size the
> pointer argument must be valid.

Is this new in C11?  Does it apply to functions such as strnlen as well?


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]