[Issue 14407] New: No protection and attributes check for class/struct allocator in NewExp

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Sat Apr 4 19:44:35 PDT 2015


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

          Issue ID: 14407
           Summary: No protection and attributes check for class/struct
                    allocator in NewExp
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Keywords: accepts-invalid
          Severity: normal
          Priority: P1
         Component: DMD
          Assignee: nobody at puremagic.com
          Reporter: k.hara.pg at gmail.com

Test case:

a.d: --------------------------------

deprecated class C
{
    private deprecated new (size_t, string)
    {
        return null;
    }
    private this(int) {}
}

deprecated struct S
{
    private deprecated new (size_t, string)
    {
        return null;
    }
    private this(int) {}
}

b.d: --------------------------------

import a;

void main() pure nothrow @safe @nogc
{
//    auto c = new("arg") C(0);
// Deprecation: class a.C is deprecated
// Deprecation: class a.C is deprecated     <-- duplicated message
// <-- no attribute errors for allocator
// <-- no access error for allocator
// Error: pure function 'D main' cannot call impure function 'a.C.this'
// Error: safe function 'D main' cannot call system function 'a.C.this'
// Error: @nogc function 'D main' cannot call non- at nogc function 'a.C.this'
// Error: class a.C member this is not accessible
// Deprecation: class a.C is deprecated
// Error: constructor this is not nothrow
// Error: function 'D main' is nothrow yet may throw

    auto s = new("arg") S(0);
// Same with class new
}

--


More information about the Digitalmars-d-bugs mailing list