[PATCH]: Fix PR tree-optimization/21407
Paul Brook
paul@codesourcery.com
Tue May 10 17:59:00 GMT 2005
> I can, in compilation unit A declare a bunch of separate structures that
> I freely use. In compilation unit B I can declare a union of all of
> those structures defined in compilation unit A. Any pointer passing
> accross the boundary between compilation units A and B can this freely
> scramble any variable defined in compilation unit A.
>
> Thus, our current type based aliasing (and I would argue any type based
> aliasing) that does not assume the worst case for any variable whose
> address may leave the compilation unit is invalid.
I though the guarantee for unions only applied when the access was actually
done through the union type.
ie. the following code has undefined behaviour:
union
{
int a;
float b;
} u;
int foo (float f)
{
u v;
int *p;
float *q;
p = &v.a;
q = &v.b;
*q = f;
return *p;
}
Paul
More information about the Gcc-patches
mailing list