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


> I wonder if, during the gcc 6 development cycle, we should experiment with a
> __builtin_side_effects_p, akin to __builtin_constant_p.  Then we could still
> follow POSIX re no side effects but even in the external context provide the
> information derivable from __builtin_unreachable.  I.e.
> 
> #define assert(X) \
>   (__builtin_side_effects_p (X) || !(X) ? 0 : __builtin_unreachable ())

It would be ideal to do this in a way that some new warning option or
fortify enablement or whatnot can give compile-time warnings about side
effects in assert expressions.  How uselessly false-positivey that would be
depends on how much a particular codebase uses the style of data gathering
or consistency-checking function calls in assert expressions (i.e., things
that the compiler would consider to have side effects, perhaps even with
complete and perfect inlining, but the programmer reasonably considers to
have no actual semantic side effects).


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