cvs commit: src/lib/libc/stdlib malloc.c

Jason Evans jasone at FreeBSD.org
Wed Apr 5 19:23:06 UTC 2006


Peter Jeremy wrote:
> On Wed, 2006-Apr-05 18:46:24 +0000, Jason Evans wrote:
> 
>>jasone      2006-04-05 18:46:24 UTC
>>
>> FreeBSD src repository
>>
>> Modified files:
>>   lib/libc/stdlib      malloc.c 
>> Log:
>> Add an unreachable return statement, in order to avoid a compiler warning
>> for non-standard optimization levels.
> 
> 
> This just masks the problem.  assert(0) is not guaranteed to abort the
> program because you can disabled asserts using NDEBUG.

I didn't make the change with any intention of catching errors in the 
non-debug case.  The change is purely about keeping the compiler quiet. 
  Note that if the assert(0) is hit, it is due to some issue that 
occurred an arbitrary amount of time earlier (like a double free), so 
catching this particular case in non-debug versions of malloc is 
essentially useless, since there's no way to associate cause and effect.

If calling abort() allows the compiler to do a better job of 
optimization than with the unreachable return statement, then there's a 
case for changing this.  Otherwise, I don't see why it matters.

Jason


More information about the cvs-src mailing list