[Bug middle-end/104492] [12 Regression] Bogus dangling pointer warning at -O3

rguenth at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Wed Mar 9 13:07:19 GMT 2022


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

--- Comment #6 from Richard Biener <rguenth at gcc dot gnu.org> ---
(In reply to Martin Sebor from comment #5)
> Setting aside the question of warning about inequality expressions involving
> invalid pointers, it seems that if the annotation 'candidates ={v}
> {CLOBBER(eol)};' is to be interpreted as one would intuitively expect -- as
> ending the variable's lifetime -- then GCC moving its use past that point
> should be considered a bug in that transformation.

The lifetime of the object ends but this is just a value and GCC cannot
distinguish for example between (uintptr_t)&candidates and &candidates
(where "leaking" the former is obviously OK).  It's similar to the
issue with __builtin_object_size and &a.b[0] vs. &a - it's nothing we can
fix.  So diagnosing uses of the _address_ (rather than the pointed to
storage) is going to have GCC generated false positives.


More information about the Gcc-bugs mailing list