www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - dmd v0.92 assert

reply Regan Heath <regan netwin.co.nz> writes:
--[test.d]--
struct A {
	uint c[5] = [
		0,
		1,
		2,
		3,
		4
	];
	void reset()
	{
		c = c.init;
	}
}

D:\D\src\build>dmd test.d
Assertion failure: '0' on line 263 in file 'init.c'

abnormal program termination

Regan

-- 
Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/
Jun 22 2004
parent reply "Walter" <newshound digitalmars.com> writes:
It's not valid to use an array initializer in an expression; a correct
message is now issued.
Jun 26 2004
parent reply Regan Heath <regan netwin.co.nz> writes:
On Sat, 26 Jun 2004 13:09:18 -0700, Walter <newshound digitalmars.com> 
wrote:

 It's not valid to use an array initializer in an expression; a correct
 message is now issued.
What is the correct way to re-initialise an array? uint c[5] = [0,1,2,3,4]; c[] = c.init; ? Regan -- Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/
Jun 26 2004
parent reply Regan Heath <regan netwin.co.nz> writes:
On Sun, 27 Jun 2004 17:16:43 +1200, Regan Heath <regan netwin.co.nz> wrote:

 On Sat, 26 Jun 2004 13:09:18 -0700, Walter <newshound digitalmars.com> 
 wrote:

 It's not valid to use an array initializer in an expression; a correct
 message is now issued.
What is the correct way to re-initialise an array? uint c[5] = [0,1,2,3,4]; c[] = c.init; ? Regan
Or maybe foreach(inout uint u; c) u = u.init; if so, it would be nice if there was a shorthand way, like c[] = c[].init or something. Regan -- Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/
Jun 26 2004
parent reply "Walter" <newshound digitalmars.com> writes:
The way right now to do it is create a static version of the array
initializer, then copy it into the arrays you want to reset.

"Regan Heath" <regan netwin.co.nz> wrote in message
news:opr98mp6mv5a2sq9 digitalmars.com...
 On Sun, 27 Jun 2004 17:16:43 +1200, Regan Heath <regan netwin.co.nz>
wrote:
 On Sat, 26 Jun 2004 13:09:18 -0700, Walter <newshound digitalmars.com>
 wrote:

 It's not valid to use an array initializer in an expression; a correct
 message is now issued.
What is the correct way to re-initialise an array? uint c[5] = [0,1,2,3,4]; c[] = c.init; ? Regan
Or maybe foreach(inout uint u; c) u = u.init; if so, it would be nice if there was a shorthand way, like c[] = c[].init or something. Regan -- Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/
Jun 27 2004
parent reply Regan Heath <regan netwin.co.nz> writes:
On Sun, 27 Jun 2004 11:13:24 -0700, Walter <newshound digitalmars.com> 
wrote:
 The way right now to do it is create a static version of the array
 initializer, then copy it into the arrays you want to reset.
Ok, so what is the point of the arrays' .init property then? Regan
 "Regan Heath" <regan netwin.co.nz> wrote in message
 news:opr98mp6mv5a2sq9 digitalmars.com...
 On Sun, 27 Jun 2004 17:16:43 +1200, Regan Heath <regan netwin.co.nz>
wrote:
 On Sat, 26 Jun 2004 13:09:18 -0700, Walter <newshound digitalmars.com>
 wrote:

 It's not valid to use an array initializer in an expression; a 
correct
 message is now issued.
What is the correct way to re-initialise an array? uint c[5] = [0,1,2,3,4]; c[] = c.init; ? Regan
Or maybe foreach(inout uint u; c) u = u.init; if so, it would be nice if there was a shorthand way, like c[] = c[].init or something. Regan -- Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/
-- Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/
Jun 27 2004
parent reply "Walter" <newshound digitalmars.com> writes:
"Regan Heath" <regan netwin.co.nz> wrote in message
news:opr99vd3pd5a2sq9 digitalmars.com...
 On Sun, 27 Jun 2004 11:13:24 -0700, Walter <newshound digitalmars.com>
 wrote:
 The way right now to do it is create a static version of the array
 initializer, then copy it into the arrays you want to reset.
Ok, so what is the point of the arrays' .init property then?
It actually gives you a null value, because that is the default initializer for [] arrays.
Jun 27 2004
parent Regan Heath <regan netwin.co.nz> writes:
On Sun, 27 Jun 2004 21:15:10 -0700, Walter <newshound digitalmars.com> 
wrote:

 "Regan Heath" <regan netwin.co.nz> wrote in message
 news:opr99vd3pd5a2sq9 digitalmars.com...
 On Sun, 27 Jun 2004 11:13:24 -0700, Walter <newshound digitalmars.com>
 wrote:
 The way right now to do it is create a static version of the array
 initializer, then copy it into the arrays you want to reset.
Ok, so what is the point of the arrays' .init property then?
It actually gives you a null value, because that is the default initializer for [] arrays.
Aha! I thought so, so.. why not turn this: uint[5] c = [0,1,2,3,4]; into 2 arrays, 1 array 'c', and 1 static array which is assigned to the c's init property (instead of null), so that: c = c.init; will then re-initialise the array. For this: uint[] c; init would remain null and c = c.init; would be identical to c = null; which works doesn't it? Regan. -- Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/
Jun 27 2004