This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc 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: [PATCH B2/2] Use builtin_unreachable in assert


On 02 Mar 2015 14:56, Roland McGrath wrote:
> > i'm not sure this is the way to go.  the expectation (as required by POSIX)
> > is that you're guaranteed there are no side-effects when NDEBUG is applied
> > to assert.  by using __builtin_unreachable, that is no longer the case.
> 
> The requirement (which should be in ISO C, not in POSIX) is specified at
> the C language level.

i don't have an ISO C reference, so i look at POSIX, and it explicitly defines 
it this way.

> "No side effects" at the C level certainly does not
> preclude a different correct translation of the program to machine code.

sure ... i wasn't saying otherwise.  my point is that __builtin_unreachable 
doesn't do that -- it explicitly is documented by gcc as:
  If control flow reaches the point of the __builtin_unreachable, the program is 
  undefined.

if there was a solution as Richard alluded to that allows for expansion of the 
expression all the time w/out breaking things when the assert is actually hit, 
i'm all for that.
-mike

Attachment: signature.asc
Description: Digital signature


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