https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83169
--- Comment #2 from Iain Buclaw <ibuclaw at gdcproject dot org> ---
A little bit of consistency?
This was found in another language where NRVO is consistency expected to
happen. Having a quick look at bug 58055, seems to suggest that front-end
should generate better codegen if the optimizer doesn't understand the intent.
I wonder what Ada does, but I'd like to avoid doing something complex such as
generating a hidden parameter to store the result.
e.g:
---
Stest footest() // fn type is really: void(Stest *hidden)
{
Stest data = {}; // *hidden = {};
ptest = &data; // ptest = hidden;
return data; // return;
}
int main()
{
const Stest data = footest(); // Stest data;
// footest (&data);
assert(ptest == &data);
return 0;
}
---