www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 15632] New: Calling delete on scope class should be an error?

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

          Issue ID: 15632
           Summary: Calling delete on scope class should be an error?
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: ibuclaw gdcproject.org

Example:
---
void f()
{
    scope A a = new A();
    delete a;
}
---

Produces the following codegen, which is not entirely desirable.
---
void f()
{
  A a = A.init;
  __ctor (&a);

  _d_callfinalizer (a);
  _d_callfinalizer (a);  // Call always inserted by the compiler.
}
---

See here for when it came up.

https://github.com/D-Programming-Language/dmd/pull/4860/files#diff-59055e7d57cf8be77c7e30104955e8fdL640

--
Jan 31