[Issue 16747] New: Cannot have stack allocated classes in @safe code

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Thu Nov 24 04:25:23 PST 2016


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

          Issue ID: 16747
           Summary: Cannot have stack allocated classes in @safe code
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: regression
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: bugzilla at digitalmars.com

The following fails:

  void foo() @safe {
    scope o = new Object();
  }

with:

  Error: delete o is not @safe but is used in @safe function foo

because o is allocated on the stack and the destructor gets called. But in this
case there is no destructor, and no deallocation, so the unsafe delete call is
unnecessary.

This problem was introduced by a fix to:

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

and change:

  https://github.com/dlang/dmd/commit/e64ae1d3e5aa078a036242864a68499617c9b278

--


More information about the Digitalmars-d-bugs mailing list