https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79992
--- Comment #15 from Yanai <yanai.eli11 at gmail dot com> --- > How so? SRA has > > > [t1.cc:10:47] [t1.cc:10:47] D.36138.v = [t1.cc:24:29] &[t1.cc:24:20] > > MEM[(const struct __lambda0 *)[t1.cc:17:42] &D.36138].__i; > ... > > [t1.cc:17:42] D.36138 ={v} {CLOBBER}; > ... > > [t1.cc:32:11] _2 = [t1.cc:32:11] *_39; > > so access *_39 after the clobber. And _39 points to D.36138. > > Clearly this is an invalid testcase. > > static auto get_wrapped_number() { > return [i = 1] { return &i; }; > } > > returns an address to automatic storage. I got why the code is not a GCC bug: `auto v = need_pie_2.get();`, does copy constructor, and it copies the pointer from the object that is immediately after going to be destructed.