www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - disabled Propagating to Classes?

reply Andrew Wiley <wiley.andrew.j gmail.com> writes:
Is this a bug?

```
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
}
```

It doesn't seem like disabled default constructors should propagate this way.
Dec 16 2011
parent reply Timon Gehr <timon.gehr gmx.ch> writes:
On 12/16/2011 09:20 PM, Andrew Wiley wrote:
 Is this a bug?

 ```
 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
 }
 ```

 It doesn't seem like disabled default constructors should propagate this way.
Definitely a bug. This has been brought up before, but I think that there is no bug report yet.
Dec 16 2011
parent Andrew Wiley <wiley.andrew.j gmail.com> writes:
On Fri, Dec 16, 2011 at 2:28 PM, Timon Gehr <timon.gehr gmx.ch> wrote:
 On 12/16/2011 09:20 PM, Andrew Wiley wrote:
 Is this a bug?

 ```
 struct SomeStruct {
 =A0 =A0 =A0 =A0 disable this();
 =A0 =A0 =A0 =A0this(int arg) {
 =A0 =A0 =A0 =A0}
 }

 class SomeClass {
 =A0 =A0 =A0 =A0private:
 =A0 =A0 =A0 =A0SomeStruct _stuff;

 =A0 =A0 =A0 =A0public:
 =A0 =A0 =A0 =A0this() {
 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0_stuff =3D SomeStruct(10);
 =A0 =A0 =A0 =A0}
 }

 void someFunc() {
 =A0 =A0 =A0 =A0SomeClass obj =3D new SomeClass(); // Error: default cons=
truction is
 disabled for type SomeClass
 }
 ```

 It doesn't seem like disabled default constructors should propagate this
 way.
Definitely a bug. This has been brought up before, but I think that there=
is
 no bug report yet.
Filed: http://d.puremagic.com/issues/show_bug.cgi?id=3D7121
Dec 16 2011