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