-Wstrict-aliasing=2

  • -Wstrict-aliasing
    • -fstrict-aliasing (-O2, -O3, -Os でも暗黙的に付加) も付加しないと警告は出力されない.
    • C 言語の規格にある strict aliasing rules を破っており,最適化で結果が不定になり得るケースで警告を出力する.
    • -Wall でも暗黙的に付加される.
  • -Wstrict-aliasing=2
    • -Wstrict-aliasing の強化版.もしかしたら問題が無いかもしれないケースでも警告を出力.

(GCC info の原文)

  • Wstrict-aliasing

This option is only active when -fstrict-aliasing is active. It warns about code which might break the strict aliasing rules that the compiler is using for optimization. The warning does not catch all cases, but does attempt to catch the more common pitfalls. It is included in -Wall.

  • Wstrict-aliasing=2

This option is only active when -fstrict-aliasing is active. It warns about code which might break the strict aliasing rules that the compiler is using for optimization. This warning catches more cases than -Wstrict-aliasing, but it will also give a warning for some ambiguous cases that are safe.