Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 05 Apr 2006 12:23:01 -0700
From:      Jason Evans <jasone@FreeBSD.org>
To:        Peter Jeremy <peterjeremy@optushome.com.au>
Cc:        cvs-src@freebsd.org, src-committers@freebsd.org, cvs-all@freebsd.org
Subject:   Re: cvs commit: src/lib/libc/stdlib malloc.c
Message-ID:  <44341915.9060007@FreeBSD.org>
In-Reply-To: <20060405191247.GM699@turion.vk2pj.dyndns.org>
References:  <200604051846.k35IkOb1025667@repoman.freebsd.org> <20060405191247.GM699@turion.vk2pj.dyndns.org>

next in thread | previous in thread | raw e-mail | index | archive | help
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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?44341915.9060007>