[Bug c++/68767] [5 regression] spurious warning: null argument where non-null required
manu at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Wed Dec 9 17:49:00 GMT 2015
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68767
--- Comment #5 from Manuel López-Ibáñez <manu at gcc dot gnu.org> ---
(In reply to Jorn Wolfgang Rennecke from comment #3)
> (In reply to Manuel López-Ibáñez from comment #2)
> > I don't understand. It is indeed passing NULL to a non-null function. What
> > is wrong with the warning?
>
> When you look at the original testcase closely, you'll see that it can never
> (unless there is a race condition, invoking undefined behaviour) pass NULL.
> In fact, it always passes "lstr" .
Well, fold_for_warn() is not smart enough to see this, unfortunately.
Optimizations in the middle-end do, but this is too late for the warning and
only works with -O1 or higher.
Either we make fold_for_warn() smarter or you work-around the warning (use ""
instead of 0 or separate the argument into a different statement).
More information about the Gcc-bugs
mailing list