On Sun, 11 Sep 2011 19:57:12 +0200, Walter Bright <[email protected]> wrote:

On 9/11/2011 9:08 AM, Max Samukha wrote:
This test case

struct S
{
@disable this();
this(int x)
{
}
}

class C
{
S s;
this()
{
s = S(42);
}
}

void main()
{
auto c = new C;
}

yields Error: default construction is disabled for type C

Is it a bug?

No, it's a feature!

Surely this must be a mistake. A class's constructor is always called when it
is created, and for non-default constructors, an uninitialized value with
@disable this() is detected. There *needs* to be a way to re-enable default
construction for classes containing structs with disabled default
constructors.

If this is simply something that is not yet done, that's fine.

--
  Simen

Reply via email to