[Bug tree-optimization/35200] [4.3 Regression] bogus aliasing warning
rguenth at gcc dot gnu dot org
gcc-bugzilla@gcc.gnu.org
Thu Feb 14 21:20:00 GMT 2008
------- Comment #7 from rguenth at gcc dot gnu dot org 2008-02-14 21:19 -------
ISO C even disallows type-punning with unions (which is in fact a GNU
extension):
union { int i; float f } u;
u.i = 1;
return u.f;
invokes undefined behavior in ISO C. You have to use memcpy and two different
memory objects like
int i = 1;
float f;
memcpy (&f, &i, 4);
return f;
to be portable and ISO C conformant.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35200
More information about the Gcc-bugs
mailing list