Summary: Structs with Disabled Default Constructors Also
                    Disable No-Arg Constructors in Classes
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD

--- Comment #0 from Andrew Wiley <> 2011-12-16 13:02:15 PST 
Code sample:
struct SomeStruct {
       @disable this();
       this(int arg) {

class SomeClass {
       SomeStruct _stuff;

       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).

Configure issuemail:
------- You are receiving this mail because: -------

Reply via email to