https://gcc.gnu.org/bugzilla/show_bug.cgi?id=124821
--- Comment #3 from Drea Pinski <pinskia at gcc dot gnu.org> ---
MEM[(struct _Alloc_hider *)&D.49187]._M_p = &D.49187.D.35932._M_local_buf;
MEM[(char_type &)&D.49187 + 16] = 0;
MEM[(struct basic_string *)&D.49187]._M_string_length = 0;
D.56784._M_len = 0;
MEM <const char *> [(struct basic_string_view *)&D.56784 + 8B] =
&D.49187.D.35932._M_local_buf;
_5 = foo (D.56784);
<bb 3> [local count: 1073741824]:
_14 = D.49187._M_dataplus._M_p;
The string escapes at foo and could in theory change.
I don't see how to fix this without much information on what foo does.
Adding:
```
[[gnu::noinline,gnu::noclone]]
extern int foo (std::string_view s)
{
return s[0];
}
```
Does allow GCC to figure out that s's values does not escape and such.