This is the mail archive of the
libc-alpha@sources.redhat.com
mailing list for the glibc project.
Re: __assert_fail should not be __attribute__((__noreturn__))
On Dienstag, 6. April 2004 05:51, Richard Henderson wrote:
> On Mon, Apr 05, 2004 at 09:23:17PM +0200, Johannes Sixt wrote:
> > These optimization opportunities are only available if assert() is used,
> > but NDEBUG is _not_ used. That is, the optimzed code is payed with the
> > runtime needed to evaluate the condition.
>
> For now, with gcc. Other compilers arrange for assert with NDEBUG
> to expand to something that generates no code, yet provides the
> compiler with the same information. GCC may eventually do something
> similar.
That's great.
But I am interested in the case where NDEBUG is _not_ used.
I assume the following:
- Developers know that assert() without NDEBUG produces slower code (because
the condition must be evaluated).
- They use NDEBUG when they compile production code.
What is wrong with these assumptions?
__builtin_expect() (as is used in the recent assert() implementation) already
does a good job to move the failure path out of the way. It is true that
removing noreturn from __assert_fail() reduces the optimization
opportunities, but only in the case that is already slow.
-- Hannes