[Bug tree-optimization/53663] [4.7/4.8 Regression] inconsistent inline handling of bool within union
rguenth at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Mon Sep 24 13:14:00 GMT 2012
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53663
--- Comment #14 from Richard Guenther <rguenth at gcc dot gnu.org> 2012-09-24 13:14:00 UTC ---
We still want to possibly optimize
extern void abort (void);
union u
{
int i;
_Bool b;
};
void f(union u * vp, union u v)
{
*vp = v;
}
int main()
{
union u v;
union u v1;
union u v2;
v.i = 0;
f(&v1, v);
v.b = 0;
f(&v2, v);
if (v2.b != 0)
abort ();
return 0;
}
though we might be able to trigger TBAA issues when removing a store
that would merely change the effective type (without changing the
underlying value). Of course we try hard (on the tree level) to
make DWIM code work, but still ... thus,
<float> = 1.;
<int> = 0;
<float> = 0.;
... = <float>;
if we remove the store <float> = 0. as redundant (it stores a value
already there) then further optimizations might re-order the float
and the int store. We don't perform redundant store elimination here
because 0. and 0 are not operand_equal_p though - but it works for shorts.
extern void abort (void);
union u
{
int i;
short f;
} v;
short foo (short *f)
{
*f = 1;
v.i = 0;
v.f = 0;
return *f;
}
int main()
{
if (foo (&v.f) != 0)
abort ();
return 0;
}
(still doesn't break though).
More information about the Gcc-bugs
mailing list