https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100994

--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Though, SRA isn't really needed, consider following testcase with
-O2 -fno-early-inlining -fno-tree-sra -fno-tree-fre

struct S { unsigned b : 4; unsigned c : 9; } const d;
__attribute__((noipa)) void foo (void) {}
static int bar (const struct S l) {
  ((struct S *)&l)->b += 2;
  ((struct S *)&l)->c += 4;
  foo ();
  return l.b + l.c;
}
int main () { bar (d); return 0; }

This also worked fine with r12-433 and segfaults with r12-434 because it will
store to d.b and d.c (instead of modifying an automatic variable).
But even if it doesn't bind to a static .rodata variable where stores will
segfault, but binds to caller's automatic variable, this binding might change
the caller's variable.

Perhaps the tree-inline.c change is fine for Ada, but it doesn't seem to be
safe for C/C++.

Reply via email to