This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/41874] Incorrect "dereferencing type-punned pointer will break strict-aliasing rules" warning
- From: "rguenth at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 31 Jan 2010 11:17:52 -0000
- Subject: [Bug c++/41874] Incorrect "dereferencing type-punned pointer will break strict-aliasing rules" warning
- References: <bug-41874-13604@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #6 from rguenth at gcc dot gnu dot org 2010-01-31 11:17 -------
(In reply to comment #5)
> Isn't this a wrong-code bug? Or is the information used for the diagnostic not
> used by the optimizers?
The diagnostics are independent on the optimizers, the one diagnostic that
isn't (that is emitted from the optimizer itself) causes the optimizer to
not optimize (well, because it saw the problem and thus there is no point
in breaking things just because we can).
The general problem is that alias analysis is hard, thus follows that proper
warnings are equally hard. All warnings we emit are either possible false
positives or if they are not the optimizers will not miscompile your code
because they know there is an alias even though type-based analysis says
there is not (well, this is exactly the case you want to warn about, but
as analysis is hard once you can tell you can as well not exploit the
mis-optimization opportunity).
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41874