https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118763

--- Comment #4 from Valentin Tolmer <valentin at tolmer dot fr> ---
I noticed that the standard (or at least cppreference) says that "The call to
the allocation function (operator new) is sequenced before(since C++17) the
evaluation of the constructor arguments in a new expression."

I'm not sure what that entails for statement expressions. On the one hand, I
can see that the current behavior is a correct interpretation of the standard:
the allocation is done, then the arguments are evaluated, and we return from
the function with no destructors to run. On the other hand, that's quite
painful for the use case in question. The only way I can see to fix that is to
document that you shouldn't return inside the constructor arguments of a new,
and possibly implement a clang-tidy check to enforce that.

Reply via email to