This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/34552] optimization of bit-shifts leads to strange results
- 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: 22 Dec 2007 05:38:56 -0000
- Subject: [Bug c/34552] optimization of bit-shifts leads to strange results
- References: <bug-34552-15540@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #2 from pinskia at gcc dot gnu dot org 2007-12-22 05:38 -------
uint32_t* foo = (uint32_t*)&z;
zbuf[3] = ((*foo) & 0x000000ffL);
It is obvious you are violating C/C++ aliasing rules which leads to undefined
behavior.
Use either -fno-strict-aliasing, an union, or memcpy.
*** 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=34552