https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112350
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
With optimization enabled and without -fsanitize=address we get:
<source>: In function 'const int& foo1()':
<source>:12:18: warning: using a dangling pointer to 'x' [-Wdangling-pointer=]
12 | return s.get();
| ^
<source>:9:9: note: 'x' declared here
9 | int x = 234;
| ^
