https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109945
--- Comment #17 from rguenther at suse dot de <rguenther at suse dot de> --- On Wed, 24 May 2023, jakub at gcc dot gnu.org wrote: > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109945 > > --- Comment #16 from Jakub Jelinek <jakub at gcc dot gnu.org> --- > I think the C version is UB, it escapes address of a local variable. The C++ > case is different when the language mandates NVR, in that case one can rely on > it. > TREE_ADDRESSABLE on a type is I think set consistently on a type, it means the > type has non-trivial copy constructor or destructor, so can't be copied > implicitly. > Widget can be copied implicitly in C++, but with mandatory NRV user can rely > on > the return value still being in scope when global is dereferenced. OK, so how can we know whether the frontend has mandatory NRV for a specific call then?