This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
-Wstrict-aliasing=2 does not warn about all problems
- From: Ian Lance Taylor <ian at airs dot com>
- To: wilson at specifixinc dot com
- Cc: gcc at gcc dot gnu dot org
- Date: 27 Jul 2005 16:53:01 -0700
- Subject: -Wstrict-aliasing=2 does not warn about all problems
Hi Jim, the documentation for -Wstrict-aliasing=2 says:
It warns about all code which might break the strict aliasing
rules that the compiler is using for optimization. This warning
catches all cases, but it will also give a warning for some
ambiguous cases that are safe.
However, there are a number of cases of aliasing which it does not
catch. For example, see PR 23106. In general, the warning is
disabled by casts through void* or char*. Also, the warning only
applies to casts of the address of a variable.
In general, I think the risky code is when we see some ordering of
these three statements:
p2 = (TYPE *) p1;
*p2;
*p1;
However, computing that is probably non-trivial.
Anyhow, I think we need to change the documentation for
-Wstrict-aliasing=2. It warns about more possible problems than
-Wstrict-aliasing, but it does not warn about all possible problems.
Any thoughts?
Ian