https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79671
--- Comment #82 from Richard Biener <rguenth at gcc dot gnu.org> ---
Btw, for the attached patch it would fail to handle the case of passing the
aggregate by value and the inliner introducing the aggregate copy:
inline void* operator new(__SIZE_TYPE__, void* __p) { return __p; }
struct X { union { int i; char s[4]; } u; };
static float foo (X y)
{
return reinterpret_cast <float &>(y.u.s);
}
int main ()
{
X x;
new (&x.u.s) float (1.0);
if (foo (x) != 1.0)
__builtin_abort ();
}
generates at -O2 after inlining:
int main() ()
{
void * D.2385;
float D.2383;
struct X y;
struct X x;
float _7;
bool retval.0_8;
<bb 2> [100.00%]:
MEM[(float *)&x] = 1.0e+0;
y = x;
_7 = MEM[(float &)&y];
...