This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/38297] O2 causes invalid code
- From: "pinskia at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 28 Nov 2008 16:52:59 -0000
- Subject: [Bug c++/38297] O2 causes invalid code
- References: <bug-38297-17012@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #7 from pinskia at gcc dot gnu dot org 2008-11-28 16:52 -------
1) Yes that is the reason why -Wstrict-aliasing exist. This is undefined
behavior at runtime not at compile time so we cannot error out. It is also the
reason why -Wstrict-aliasing is enabled with -Wall.
2) Use memcpy instead of an union if you want a portable way to type pun.
*** This bug has been marked as a duplicate of 21920 ***
--
pinskia at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |DUPLICATE
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38297