Date: Fri, 25 Jul 2025 15:32:13 +0200
The return of outer would be handled by return value optimization, effectively constructing outer in-place at a caller-defined location.
In this example it would be constructed in temporary stack space. The i refers to the inner i in f1, which is no longer in scope.
In practice, it would probably not crash, as inner has no member variables and do_something() does not dereference the this pointer.
The default constructor of outer is only called at the very end of the expression, so I do not understand, what difference it would make in regards to i.
-----Ursprüngliche Nachricht-----
Von:Jarrad Waterloo via Std-Proposals <std-proposals_at_[hidden]>
Gesendet:Fr 25.07.2025 15:33
Betreff:Re: [std-proposals] Standardising 0xdeadbeef for pointers
An:std-proposals_at_[hidden];
CC:Jarrad Waterloo <descender76_at_[hidden]>;
I am more concerned about point of deletion than creation as in your example.
struct inner
{
void do_something(){}
};
struct outer
{
inner& i;
};
outer f1()
{
inner i
return outer{i};
}
f1().i. do_something();// crash hopefully
The question is ensuring that the default destructor of outer setting its INTERNAL pointer of i to nullptr instead of it being a noop and the destructor being elided for having no code.
Received on 2025-07-25 13:42:02