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

--- Comment #6 from Jan Hubicka <hubicka at gcc dot gnu.org> ---
I am not sure we (particularly I) have a good answer for this. The warning is a
false positive, which happens in other scenarios too. For example, improvements
to std::string has triggered it too, since we free the string which may point
to local buffer which is on stack (that code path exists in cfg but not in
practice). This was eventually mitigated by improving optimization of that
sequence, but will trigger again if we i.e. run out of alias oracle walk
limits.

I think the warning should be worded "may be called on unallocated object"
since we do not know that code path is taken. I am not sure we want to have
maybe at -Wall -Werror, since they inherently may cause build failures, but
taking this into extreme, we would need to disable most of warnings. Even if
the execution point postdominates retrn block, we do not know if the function
gets called at all or if it is terminated earlier by invisible means.

In another PR we discussed disabling speculative devirt with multiple targets
at -O2.  This is a workaround - even one target speculative devirt can trigger
this, but it is also a question how much we want speculatively devirtualize at
-O2 and I don't think we have strong reason to keep it there.

The testcase is for -O3, but I assume we want to primarily cause bootstrap
failures with -O2?

Reply via email to