This is the mail archive of the
mailing list for the glibc project.
Re: [PATCH B2/2] Use builtin_unreachable in assert
- From: Roland McGrath <roland at hack dot frob dot com>
- To: Mike Frysinger <vapier at gentoo dot org>
- Cc: Richard Henderson <rth at twiddle dot net>, libc-alpha at sourceware dot org
- Date: Mon, 2 Mar 2015 14:56:37 -0800 (PST)
- Subject: Re: [PATCH B2/2] Use builtin_unreachable in assert
- Authentication-results: sourceware.org; auth=none
- References: <1420827419-18655-1-git-send-email-rth at twiddle dot net> <1420827419-18655-3-git-send-email-rth at twiddle dot net> <20150302074325 dot GB8519 at vapier>
> 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. "No side effects" at the C level certainly does not
preclude a different correct translation of the program to machine code.
> 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.
In fact, many distributions build libc with -DNDEBUG. In terms of quantity
of execution that happens, I'd bet most use of libc is with -DNDEBUG.