[PATCH B2/2] Use builtin_unreachable in assert

Mike Frysinger vapier@gentoo.org
Mon Mar 2 07:43:00 GMT 2015


On 09 Jan 2015 10:16, Richard Henderson wrote:
> Finally, use __builtin_unreachable to tell the compiler about
> impossible paths.

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.

yes, assert in this context is internal to glibc and so doesn't have to conform 
to POSIX directly.  but i think forcing developers to remember this kind of 
nuance just leads to bugs, especially when you consider glibc imports code from 
other projects (like gnulib).

the code shrinkage is attractive, but the other factors considered (and that 
NDEBUG usage in glibc in general is uncommon) leads me to think this path is 
not worth the pain.
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://sourceware.org/pipermail/libc-alpha/attachments/20150302/3cd1e81b/attachment.sig>


More information about the Libc-alpha mailing list