www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 17505] New: [REG2.075] safe constructor requires the

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

          Issue ID: 17505
           Summary: [REG2.075]  safe constructor requires the
                    deconstructor to be safe as well
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: regression
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: greensunny12 gmail.com

cat > main.d << CODE
struct Array
{
    int[] _payload;
    ~this()
    {
        import core.stdc.stdlib : free;
        free(_payload.ptr);
    }
}

class Scanner
{
    Array arr;
    this()  safe {}
}
CODE


$ dmd -main

main.d(14): Error:  safe constructor 'main.Scanner.this' cannot call  system
destructor 'main.Scanner.~this'

--
Jun 14