bison-patches
[Top][All Lists]
Advanced

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

Re: Bison torture test speedup: `assert (x);' -> `if (! (x)) abort ();'


From: Paul Eggert
Subject: Re: Bison torture test speedup: `assert (x);' -> `if (! (x)) abort ();'
Date: Tue, 12 Nov 2002 00:08:29 -0800 (PST)

> From: Akim Demaille <address@hidden>
> Date: 12 Nov 2002 08:54:49 +0100
> 
> Err...  This is shocking!  What is the difference between assert and 
> if/abort???

assert (FOO) preprocesses into this code:

  (void)((FOO) || (__assert("1", "t.c", 6), 0));

whereas 'if (! (FOO)) abort ();' is unaffected by the preprocessor.

My vague impression is that the GCC optimizer spends a lot of time
optimizing the assert code, whereas the abort code is easily
optimized.  I compile with "gcc -O -Wall" so it's important for me for
the torture test to work well even if optimization is turned on.

Typically, the GNU style is to use abort rather than assert, since we
assume that one has a debugger at hand at all times, so it's not too
surprising that assert isn't tuned well with GCC.




reply via email to

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