[Bug middle-end/44164] [4.5 Regression] Aliasing bug triggered by Boost.Bind/Boost.Function
pdimov at gmail dot com
gcc-bugzilla@gcc.gnu.org
Mon May 17 19:11:00 GMT 2010
------- Comment #7 from pdimov at gmail dot com 2010-05-17 19:10 -------
(In reply to comment #6)
> Basically the middle-end sees this the same as
> int i = 1, j;
> float *p = new (&i) float(0.0);
> j = i;
> return *reinterpret_cast<float *>(&j);
> and you expect to return 0.0.
The int/float example does violate the aliasing rules, but I don't think that
it properly describes what's happening.
I see it more like a combination of the following two examples:
#include <iostream>
struct X
{
char data[ sizeof( float ) ];
};
int main()
{
X x1;
new( &x1.data ) float( 3.14f );
X x2 = x1;
std::cout << *(float const*)&x2.data << std::endl;
}
and
#include <iostream>
union Y
{
int i;
float f;
};
int main()
{
Y y1;
y1.f = 3.14f;
Y y2 = y1;
std::cout << y2.f << std::endl;
}
I don't think either of them violates the standard.
--
pdimov at gmail dot com changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |pdimov at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44164
More information about the Gcc-bugs
mailing list