[Issue 7121] New: Structs with Disabled Default Constructors Also	Disable No-Arg Constructors in Classes
    d-bugmail at puremagic.com 
    d-bugmail at puremagic.com
       
    Fri Dec 16 13:02:17 PST 2011
    
    
  
http://d.puremagic.com/issues/show_bug.cgi?id=7121
           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
        AssignedTo: nobody at puremagic.com
        ReportedBy: debio264 at gmail.com
--- Comment #0 from Andrew Wiley <debio264 at gmail.com> 2011-12-16 13:02:15 PST ---
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).
-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
    
    
More information about the Digitalmars-d-bugs
mailing list