Bug 14407 – No protection and attributes check for class/struct allocator in NewExp
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2015-04-05T02:44:00Z
Last change time
2016-02-01T10:30:44Z
Keywords
accepts-invalid, pull
Assigned to
nobody
Creator
k.hara.pg
Comments
Comment #0 by k.hara.pg — 2015-04-05T02:44:35Z
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-@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
}