www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 7121] New: Structs with Disabled Default Constructors Also Disable No-Arg Constructors in Classes

reply d-bugmail puremagic.com writes:
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 puremagic.com
        ReportedBy: debio264 gmail.com



---
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: -------
Dec 16 2011
parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7121


Simen Kjaeraas <simen.kjaras gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |wfunction hotmail.com



PDT ---
*** Issue 8117 has been marked as a duplicate of this issue. ***

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jul 27 2012