Bug 7121 – Structs with Disabled Default Constructors Also Disable No-Arg Constructors in Classes
Status
RESOLVED
Resolution
DUPLICATE
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2011-12-16T13:02:00Z
Last change time
2013-11-28T21:07:20Z
Assigned to
nobody
Creator
debio264
Comments
Comment #0 by debio264 — 2011-12-16T13:02:15Z
Code sample:
```
struct SomeStruct {
@disable this();
this(int arg) {
}
}
class SomeClass {
private:
SomeStruct _stuff;
public:
this() {
_stuff = SomeStruct(10);
}
}
void someFunc() {
SomeClass obj = new SomeClass(); // Error: default construction is disabled for type SomeClass
}
```
As you can see, the @disabled constructor in SomeStruct breaks the no-arg constructor in SomeClass.
Disabling the *default* constructor in SomeClass is correct, but if a no-arg constructor is implemented, it should be checked against the same rules as other constructors (and an error should occur if it doesn't initialize the @disabled struct).
Comment #1 by simen.kjaras — 2012-07-27T15:38:31Z
*** Issue 8117 has been marked as a duplicate of this issue. ***
Comment #2 by simen.kjaras — 2013-11-28T12:14:34Z
Fixed in 2.064.
Comment #3 by k.hara.pg — 2013-11-28T21:07:20Z
*** This issue has been marked as a duplicate of issue 10186 ***