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

            Bug ID: 122154
           Summary: Missing SRA due to "TREE_READONLY"
           Product: gcc
           Version: 16.0
            Status: UNCONFIRMED
          Keywords: missed-optimization
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: pinskia at gcc dot gnu.org
  Target Milestone: ---

Take:
```
struct s1
{
  int t;
};
void g(struct s1);
struct s1 min_cmp(int x, int y)
{
  return (struct s1){y};
}
const struct s1 gg(int c, int d)
{
  const struct s1 a = min_cmp(c,d);
  return (struct s1){a.t};
}
```

ESRA should total scalarize a but does NOT when compiling with the C++
front-end. With the C front-end we do the correct thing.

With the C++ front-end we get:
! Disqualifying a - Encountered a store to a read-only decl.

This is the SRA reduced testcase that I noticed from PR 122083.

I don't know if this is a front-end issue or SRA issue.

Reply via email to