Bug 19676 – Destructor not called for returned temporary that was cast to void

Status
RESOLVED
Resolution
FIXED
Severity
major
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2019-02-15T07:47:37Z
Last change time
2019-02-15T11:21:33Z
Keywords
wrong-code
Assigned to
No Owner
Creator
Walter Bright
See also
https://issues.dlang.org/show_bug.cgi?id=18573

Comments

Comment #0 by bugzilla — 2019-02-15T07:47:37Z
struct S { ~this(); } S foo(); void test1() { foo(); // Correct: destructor called } void test2() { cast(void)foo(); // Bug: destructor not called }
Comment #1 by bugzilla — 2019-02-15T07:58:35Z
Comment #2 by dlang-bot — 2019-02-15T11:21:33Z
dlang/dmd pull request #9363 "fix Issue 19676 - Destructor not called for returned temporary that w…" was merged: https://github.com/dlang/dmd/pull/9363