This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Counter intuitively, asserts hurt gcc static dataflow analysis.


On 04/05/2018 01:03, John Carter wrote:

> 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 the first version, gcc inlines the function call, which enables
further analysis. In the second version, the assert() call makes
gcc decide not to inline the function call, thus later analysis passes
are no longer able to spot the out-of-bounds access.

> This Communication is Confidential. We only send and receive email on
> the basis of the terms set out at www.taitradio.com/email_disclaimer

Obviously, such footers are silly when writing to a public mailing list.

Regards.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]