Counter intuitively, asserts hurt gcc static dataflow analysis.
Florian Weimer
fw@deneb.enyo.de
Fri May 4 15:02:00 GMT 2018
* John Carter:
> But compile with ...
> gcc -O3 -W -Wall -Wextra -o a a.c
> ...now results in NO warnings!
>
> ie. Although gcc _knows_ the assert _will_ trigger at run time... it can't
> tell me at compile time anymore.
>
> ie. Counter intuitively, adding asserts and error checks to my code has
> made me less safe.
In glibc, we could warn if the assert expression is constant and
false. But I'm worried that this will produce lots and lots of false
positives after inlining, loop unrolling, and other optimizations.
Has anyone tried something like this?
More information about the Gcc-help
mailing list