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

--- Comment #3 from Stefanus Du Toit <sjdutoit at gmail dot com> ---
This bug affects us as well. I believe the relevant part of the documentation
is:

> Jumping out of a statement expression is permitted, but if the statement 
> expression is part of a larger expression then it is unspecified which other
> subexpressions of that expression have been evaluated except where the 
> language
> definition requires certain subexpressions to be evaluated before or after
> the statement expression.

That seems very reasonable, but I think it's also reasonable to assume that if
a part of the expression _has_ been evaluated, and it involves the
initialization of one or more temporaries, that those temporaries are properly
destructed when the function scope is exited.

Utkarsh's reproducer prints:

  Printy(a)
  Printy(b)
  ~Printy(b)

the Printy(a) object is evaluated before the stmt-expr, which is fine. But
given that it _has_ been evaluated, and is now going out of scope, its
destructor should also be called on the way out.

Reply via email to