[Issue 21586] Struct dtor is called twice if struct is created inside ternary operator
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Wed Jan 27 09:33:11 UTC 2021
https://issues.dlang.org/show_bug.cgi?id=21586
RazvanN <razvan.nitu1305 at gmail.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
CC| |razvan.nitu1305 at gmail.com
Resolution|--- |INVALID
--- Comment #2 from RazvanN <razvan.nitu1305 at gmail.com> ---
(In reply to Temtaime from comment #0)
As moonlightsentinel highlighted, the variable is destroyed only once. The code
in main is roughly translated to this:
void main()
{
S tmp;
auto s = (true ? tmp = S(1) : tmp = S(0); tmp);
tmp.__dtor;
s.__dtor;
}
This is the intended behavior. Closing as invalid.
--
More information about the Digitalmars-d-bugs
mailing list