bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: use of __builtin_trap


From: Paul Eggert
Subject: Re: use of __builtin_trap
Date: Sat, 11 Aug 2018 23:41:55 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1

Bruno Haible wrote:
Would it be possible to use abort () instead of __builtin_trap ()?

It would, but I'm not sure it'd be a good idea, as assume(X) is not intended to be a safety check: it's intended to be a message from the programmer to static analysis tools such as GCC's optimizer and/or warner.

assume(X) uses __builtin_trap only in GCC versions 3.3.4 through 4.4.7, which are so old that it's fair to call them obsolescent. In more-recent versions of GCC, assume(X) uses __builtin_unreachable, which means that when X is false the machine code can do anything at all. The main reason __builtin_trap is called on older GCCs is to pacify them when warnings are enabled. 'abort' is no better for that purpose, and to some extent is worse as it brings in stdlib.h and typically generates even more more useless bloat in the executable.

I suppose we could remove the call to __builtin_trap on older GCCs, and have assume (X) be a complete no-op with GCC 3.3.4 through 4.4.7. But this would cause even more chatter when people compile with warnings on these obsolescent platforms (a mistake if you ask me, but people do it...), and this cost exceeds any benefit I can see from removing the call.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]