www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - struct with disable(d) default constructor doesn't work with arrays?

reply "Minas Mina" <minas_mina1990 hotmail.co.uk> writes:
I have this struct:

struct S
{
	int[] t;
	
	 disable this();
	
	this(int sz)
	{
		t = new int[sz];
		t[] = 1;
	}
	
	S opCall(int sz)
	{
		S s = S(sz);
		return s;
	}
	
	this(this)
	{
		t = t.dup;
	}
}


Naturally, this doesn't work:
S s; // compiler error

However this does compile.
S[100] s;


S[100] s;	
writeln(s[0].t[0]); // range violation error!

I think it's a bug, what do you think?
Aug 22 2012
parent reply "bearophile" <bearophileHUGS lycos.com> writes:
Minas Mina:

 I think it's a bug, what do you think?
Search for it in Bugzilla. Maybe it's there already. Bye, bearophile
Aug 22 2012
parent "Simen Kjaeraas" <simen.kjaras gmail.com> writes:
On Wed, 22 Aug 2012 13:09:49 +0200, bearophile <bearophileHUGS lycos.com>  
wrote:

 Minas Mina:

 I think it's a bug, what do you think?
Search for it in Bugzilla. Maybe it's there already. Bye, bearophile
-- Simen
Aug 22 2012