[Bug c++/70403] A null pointer check removed with -O2 even with -fno-delete-null-pointer-checks

thadula at ciena dot com gcc-bugzilla@gcc.gnu.org
Fri Apr 1 15:26:00 GMT 2016


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70403

--- Comment #12 from Hadula, Tomasz <thadula at ciena dot com> ---
> The reduced testcase doesn't have the pattern you describe in
> the description.

Well, of course, I couldn't verify that for sure, because the reduced testcase
was so severely mutilated that I couldn't possibly use to generate a running
program. However when I was looking into the output produced by
-fdump-tree-optimized I could see that pNewSel_2 in <bb 12> in CpSelect was not
tested for null.

> Compiling with -fsanitize=undefined would have found that bug.

I tried that earlier, but the whole executable is so heavy that I couldn't even
have it started in the realistic time. So sanitizing it during runtime is the
challenge that we keep working on, but not there yet. Static analysis would
work better for us.

Is there any option that could point out any undefined behavior and print it as
a warning? (e.g. -Wundefined ? /but under 4.9.2 it is not recognized option/)

Anyway thank you very much for your help. I'm so glad that it gave us
opportunity to put that bug to rest eventually. Right about the time I posted
the reduced testcase yesterday, we have found many more occurrences of that bug
in other places in the code involving different classes, but the pattern seems
to be the same. In the first preprocessed source I attached, you could find at
least one more. Hard to say was the original idea behind it, but looking at the
source control it seems to be there since beginning of time. It's like way over
a decade old bug.

I still don't understand though why - since "pCpId" was responsible for
undefined behavior - why did devirtualization pick on "pNewSel" (and also in
the original source: on "squelch")?


More information about the Gcc-bugs mailing list