www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 19676] New: Destructor not called for returned temporary that

https://issues.dlang.org/show_bug.cgi?id=19676

          Issue ID: 19676
           Summary: Destructor not called for returned temporary that was
                    cast to void
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: major
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: bugzilla digitalmars.com

struct S {
    ~this();
  }

  S foo();

  void test1() {
    foo();      // Correct: destructor called
  }

  void test2() {
    cast(void)foo();   // Bug: destructor not called
  }

--
Feb 14 2019