This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/51885] g++ compiler options -O2 and -O3 modifies program results
- From: "manu at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 18 Jan 2012 10:02:04 +0000
- Subject: [Bug c++/51885] g++ compiler options -O2 and -O3 modifies program results
- Auto-submitted: auto-generated
- References: <bug-51885-4@http.gcc.gnu.org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51885
Manuel LÃpez-IbÃÃez <manu at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |manu at gcc dot gnu.org
--- Comment #3 from Manuel LÃpez-IbÃÃez <manu at gcc dot gnu.org> 2012-01-18 10:02:04 UTC ---
(In reply to comment #2)
> The reinterpret_cast definitely results in undefined behaviour, because it
> accesses the float objects through a different type, violating [basic.lval]/10
>
> And indeed, -fno-strict-aliasing makes the problem go away.
It definitely does not make the problem go away, it merely hides it. The
undefined behavior does not disappear just by using command-line options.
On the other hand, is it possible to cast a float pointer to a uint32 pointer
and use it for anything that does not invoke undefined behaviour?
GCC gives a warning with -Wstrict-aliasing=1 but no with other levels.