On 5/23/20 9:54 AM, Marc Nieper-Wißkirchen wrote:

> Sure, but not in "-O0" or "-Og" builds, I think. Or am I mistaken?

Probably not for -O0. I'm not so sure for -Og. Either way, we shouldn't rely on
GCC's current behavior in this area as it is neither documented nor guaranteed
to stay the same.

> #include <assert.h>
> #include "verify.h"
> 
> #ifdef NDEBUG
> # define checked_assume(E) assume (E)
> #else
> # define checked_assume(E) assert (E)
> #endif

Something like that would work, though the name "checked_assume" is misleading
since the assumption is not always checked.

"affirm (E)" would be a better name, since the name's not being used anymore by
the old software verification project[1] and it slides in well next to "assume"
and "assert". (Some day we're going to run out of synonyms. :-)

[1] http://www.softwarepreservation.org/projects/verification/affirm/

Reply via email to