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

--- Comment #10 from Xi Ruoyao <xry111 at gcc dot gnu.org> ---
(In reply to Adam Andersson from comment #9)
> I was sure I had tried -fno-strict-aliasing without any difference, but I
> guessed I messed up somehow. Sorry about that.
> 
> Still, is it not strange that -Wall doesn't generate a warning about this
> then?

-Wall only enables -Wstrict-aliasing=3 which may have false negatives.

-Wstrict-aliasing=1 or -Wstrict-aliasing=2 warns about this, but generally they
can produce many false positives (as they are documented).

Generally it's impossible to make a reliable way to detect aliasing violation
at compile time.  For runtime checking LLVM folks were developing a Type
Sanitizer
(https://llvm.org/devmtg/2017-10/slides/Finkel-The%20Type%20Sanitizer.pdf) but
the development seems stalled now.

Thus we document "try -fno-strict-aliasing" in the "new bug" page as a "not so
bad" way to rule out aliasing issues (it's only "not so bad", not "very good"
because it may still hide real bugs).

Reply via email to