[Bug c/103502] -Wstrict-aliasing=3 doesn't warn on what is documented as UB

egallager at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Wed Dec 1 00:28:34 GMT 2021


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

Eric Gallager <egallager at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |egallager at gcc dot gnu.org

--- Comment #6 from Eric Gallager <egallager at gcc dot gnu.org> ---
(In reply to Andrew Pinski from comment #1)
> The documentation
> (https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#Warning-Options)
> for the warning is clear here:
> "Takes care of the common pun+dereference pattern in the front end:
> *(int*)&some_float. "
> 
> >3 is documented as the most precise option
> 
> I think you misunderstood what precise means in this context really.
> "Higher levels correspond to higher accuracy (fewer false positives). "

-Wstrict-aliasing is kind of confusing in this regards since it's different
from how other warnings with numerical levels work. Normally a higher numerical
value to a warning option means "print more warnings" but for -Wstrict-aliasing
it means "try harder to reduce the number of warnings". Perhaps this is an
inconsistency that should be rectified?


More information about the Gcc-bugs mailing list