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

--- Comment #9 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Andrew Pinski from comment #8)
> (In reply to Arthur O'Dwyer from comment #7)
> > // https://godbolt.org/z/Ea43Y65z4
> > struct Widget {
> >     int i = 1;
> ...
> > In this case, Widget has no constructors,
> 
> No, it has a constructor because of the NSDMI . NSDMI causes a non-trival
> constexpr constructor to be created.

Now this version does not:
```
struct Widget {
    int i;
    int a[4];
};
Widget *global = 0;
Widget make2() { Widget w; w.i = 1; global = &w; return w; }
void g() { global->i = 42; }
int main() {
  Widget w = make2();
  int i = w.i;
  g();
  return (i == w.i);
    // Does this need to be reloaded and
    // compared? or is it obviously true?  
}
```

But does w go out of the scope at the end of make2? Similar question to make in
the original testcase, does the temp go out of scope?

Reply via email to