On Jul 14, 9:36 am, "Francesco S. Carta" <entul...@gmail.com> wrote:
According to what I see above, the object gets destroyed right
after the
end of the call to that static function, so I think you're NOT safe
using that reference afterwards.
I repeat, that's just an empirical test, I have no idea about what the
standard mandates about it, although I feel it's UB at least.
Mehhh... [class.temporary] says the temp should exist until the end of
the full expression. So you might be able to do something like
MyClass b = GetMyClass(MyClass());
and effectively assign to b from the temporary. But it's not at all
clear to me what a full-expression is. I mean, it's defined in
[intro.execution] but then it lists some exceptions to the rule,
which seem to muddy the issue for me.
part of the expression used to invoke GetMyClass. Using a dangling
concerned.