This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/34295] Bad optimization in an inlined method
- 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: 29 Nov 2007 17:21:13 -0000
- Subject: [Bug c++/34295] Bad optimization in an inlined method
- References: <bug-34295-15458@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #3 from rguenth at gcc dot gnu dot org 2007-11-29 17:21 -------
The recommended (and optimized) way to do this is:
union {
INT64 i;
double d;
} x;
x.d = arg;
return x.i;
you can also make your way work optimized by specifying -fno-strict-aliasing.
That it works without optimization is because with that or with -O1
-fno-strict-aliasing is default.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34295