www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - DMD-0.123 introduced bug

reply "Andrew Fedoniouk" <news terrainformatica.com> writes:
Following:

struct Two // <<<<<<<<<<<<<
{
  int i;
}

static Two[12] Twos = [];

int main(char[][] argv)
{
  return 0;
}

reports:

test.d(3): non-constant expression _init_4test3Two
test.d(3): non-constant expression _init_4test3Two
... 12 times ...

Harmonia is broken :( 
May 13 2005
next sibling parent reply "Walter" <newshound digitalmars.com> writes:
"Andrew Fedoniouk" <news terrainformatica.com> wrote in message
news:d63bn0$11v$1 digitaldaemon.com...
 Following:

 struct Two // <<<<<<<<<<<<<
 {
   int i;
 }

 static Two[12] Twos = [];
static Two[12] Twos;
 int main(char[][] argv)
 {
   return 0;
 }

 reports:

 test.d(3): non-constant expression _init_4test3Two
 test.d(3): non-constant expression _init_4test3Two
 ... 12 times ...

 Harmonia is broken :(
May 13 2005
parent reply "Andrew Fedoniouk" <news terrainformatica.com> writes:
"Walter" <newshound digitalmars.com> wrote in message 
news:d63qb4$b01$1 digitaldaemon.com...
 "Andrew Fedoniouk" <news terrainformatica.com> wrote in message
 news:d63bn0$11v$1 digitaldaemon.com...
 Following:

 struct Two // <<<<<<<<<<<<<
 {
   int i;
 }

 static Two[12] Twos = [];
static Two[12] Twos;
I know, but suppose I have (close to real situation) static Two[12] Twos = [ 2: { 2 }, 4: { 4 } ]; Compiler will not like this too. This time it will repeat error message 10 times - for each ommited element. And this is close to example you wrote in Arrays chapter in the Doc. See: array static initialization. Also: http://dstress.kuehne.cn/nocompile/array_initialization_11.d will not compile for the same reason I believe. This poped up in .123. Andrew.
May 13 2005
next sibling parent reply Thomas Kuehne <thomas-dloop kuehne.thisisspam.cn> writes:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Andrew Fedoniouk schrieb am Fri, 13 May 2005 21:46:04 -0700:
 "Walter" <newshound digitalmars.com> wrote in message 
 news:d63qb4$b01$1 digitaldaemon.com...
 "Andrew Fedoniouk" <news terrainformatica.com> wrote in message
 news:d63bn0$11v$1 digitaldaemon.com...
 Following:

 struct Two // <<<<<<<<<<<<<
 {
   int i;
 }

 static Two[12] Twos = [];
static Two[12] Twos;
I know, but suppose I have (close to real situation) static Two[12] Twos = [ 2: { 2 }, 4: { 4 } ]; Compiler will not like this too. This time it will repeat error message 10 times - for each ommited element. And this is close to example you wrote in Arrays chapter in the Doc. See: array static initialization.
Added to DStress as http://dstress.kuehne.cn/run/a/array_initialization_15.d Thomas -----BEGIN PGP SIGNATURE----- iD8DBQFChaiO3w+/yD4P9tIRAjt5AJ9LvRh1sqdjg+gDoAwTejkyu//CqwCguz3J FreaxhLS4kafOM7slpheSNQ= =TDh0 -----END PGP SIGNATURE-----
May 14 2005
parent reply Stewart Gordon <smjg_1998 yahoo.com> writes:
Thomas Kuehne wrote:
 -----BEGIN PGP SIGNED MESSAGE-----
 Hash: SHA1
 
 Andrew Fedoniouk schrieb am Fri, 13 May 2005 21:46:04 -0700:
 
"Walter" <newshound digitalmars.com> wrote in message 
news:d63qb4$b01$1 digitaldaemon.com...

"Andrew Fedoniouk" <news terrainformatica.com> wrote in message
news:d63bn0$11v$1 digitaldaemon.com...
<snip>
static Two[12] Twos = [];
static Two[12] Twos;
AIUI the point the OP is making is that the error message makes no sense. This is an instance of initialising an array with an empty array. This code succeeds (gdc 0.11 Mac): ---------- int[] data = []; void main() { assert (data.length == 0); assert (data.ptr != null); } ---------- though should the latter assert really be guaranteed? But do see below.... <snip>
 Added to DStress as
 http://dstress.kuehne.cn/run/a/array_initialization_15.d
Should be nocompile. The bug is a bad error line number. http://www.digitalmars.com/d/arrays.html "If any members of an array are initialized, they all must be. This is to catch common errors where another element is added to an enum, but one of the static instances of arrays of that enum was overlooked in updating the initializer list." Though it would be nice to have a syntax like int[6] data = [ 2: 4, 3: 9, 5: 3, default: int.init ]; to indicate that you really intended to leave some members otherwise uninitialised. Stewart. -- My e-mail is valid but not my primary mailbox. Please keep replies on the 'group where everyone may benefit.
May 16 2005
next sibling parent reply "Andrew Fedoniouk" <news terrainformatica.com> writes:
 AIUI the point the OP is making is that the error message makes no sense.

 This is an instance of initialising an array with an empty array.  This 
 code succeeds (gdc 0.11 Mac):

 ----------
 int[] data = [];

 void main() {
     assert (data.length == 0);
     assert (data.ptr != null);
 }
 ----------

 though should the latter assert really be guaranteed?

 But do see below....

 <snip>
 Added to DStress as
 http://dstress.kuehne.cn/run/a/array_initialization_15.d
Should be nocompile. The bug is a bad error line number. http://www.digitalmars.com/d/arrays.html "If any members of an array are initialized, they all must be. This is to catch common errors where another element is added to an enum, but one of the static instances of arrays of that enum was overlooked in updating the initializer list."
In fact I do not understand this statement in doc. Does it only about static arrays defined by enums? Take a look on the same page in doc but two lines above: Static Initialization of Static Arrays int[3] a = [ 1:2, 3 ]; // a[0] = 0, a[1] = 2, a[2] = 3 This example tell us completely different story. Right?> Though it would be nice to have a syntax like> > int[6] data = [ 2: 4, 3: 9, 5: 3, default: int.init ];> > to indicate that you really intended to leave some members otherwise
 uninitialised.
Agree. A bit redundant in my opinion. I thought that introducing of init values in D was exactly for such cases. And this is just enough, imho. Andrew.
May 16 2005
parent Stewart Gordon <smjg_1998 yahoo.com> writes:
Andrew Fedoniouk wrote:
<snip>
"If any members of an array are initialized, they all must be. This is to 
catch common errors where another element is added to an enum, but one of 
the static instances of arrays of that enum was overlooked in updating the 
initializer list."
In fact I do not understand this statement in doc. Does it only about static arrays defined by enums?
The first sentence of that paragraph is arrays in general. *Then* it goes on to talk about arrays that parallel enums.
 Take a look on the same page in doc but two
 lines above:
 
 Static Initialization of Static Arrays
 int[3] a = [ 1:2, 3 ];		// a[0] = 0, a[1] = 2, a[2] = 3
<snip>
 Agree. A bit redundant in my opinion.
 I thought that introducing of init values in D was exactly for such cases.
 And this is just enough, imho.
But D also aims to eliminate bugs. An incomplete initialisation of an array is an example of something likely to be a bug. On the other hand, no initialisation at all is (to me at least) a sign that you want the default initialisers to take effect. Stewart. -- My e-mail is valid but not my primary mailbox. Please keep replies on the 'group where everyone may benefit.
May 17 2005
prev sibling next sibling parent reply Thomas Kuehne <thomas-dloop kuehne.thisisspam.cn> writes:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Stewart Gordon schrieb am Mon, 16 May 2005 11:35:35 +0100:
<snip><snip>

 Added to DStress as
 http://dstress.kuehne.cn/run/a/array_initialization_15.d
Should be nocompile. The bug is a bad error line number.
What would be the correct error message for array_initialization_15? Thomas -----BEGIN PGP SIGNATURE----- iD8DBQFCii7c3w+/yD4P9tIRAq8sAKDS72PgqCE36CIq44TGnMNVXB4wlACgvhTI RisGfqtqWPDtbki98MoKm0g= =9Uao -----END PGP SIGNATURE-----
May 17 2005
parent Stewart Gordon <smjg_1998 yahoo.com> writes:
Thomas Kuehne wrote:
 -----BEGIN PGP SIGNED MESSAGE-----
 Hash: SHA1
 
 Stewart Gordon schrieb am Mon, 16 May 2005 11:35:35 +0100:
 <snip><snip>
 
Added to DStress as
http://dstress.kuehne.cn/run/a/array_initialization_15.d
Should be nocompile. The bug is a bad error line number.
What would be the correct error message for array_initialization_15?
Just thinking about it, it depends on which side of the contradiction you go by. If the first code snippet under "Static Initialization of Static Arrays" is correct, then indeed it should work. If OTOH the paragraph I quoted earlier is correct, it should be something like array_initialization_15.d(15): incomplete initialization of array s Stewart. -- My e-mail is valid but not my primary mailbox. Please keep replies on the 'group where everyone may benefit.
May 18 2005
prev sibling parent Stewart Gordon <smjg_1998 yahoo.com> writes:
Stewart Gordon wrote:
<snip>
 Though it would be nice to have a syntax like
 
     int[6] data = [ 2: 4, 3: 9, 5: 3, default: int.init ];
<snip> Even simply int[6] data = [ 2: 4, 3: 9, 5: 3, default ]; meaning use the default initialiser. Syntactic salt and sugar in one. Stewart. -- My e-mail is valid but not my primary mailbox. Please keep replies on the 'group where everyone may benefit.
May 18 2005
prev sibling parent "Walter" <newshound digitalmars.com> writes:
"Andrew Fedoniouk" <news terrainformatica.com> wrote in message
news:d63vmq$fqq$1 digitaldaemon.com...
 Also:
 http://dstress.kuehne.cn/nocompile/array_initialization_11.d
 will not compile for the same reason I believe.
 This poped up in .123.
This doesn't compile because now the compiler detects that it would overflow the stack.
May 18 2005
prev sibling parent "Jarrett Billingsley" <kb3ctd2 yahoo.com> writes:
"Andrew Fedoniouk" <news terrainformatica.com> wrote in message 
news:d63bn0$11v$1 digitaldaemon.com...

 static Two[12] Twos = [];
This is really the line that's causing the problem (looks like another funky error line diagnosis). I suppose it's legal syntax, but is there any reason you need the =[] part? They are all initialized to 0 anyway. So for the time being, you can write static Two[12] Twos; Although I'm not sure what that error is supposed to mean, or why the compiler is flagging it as such.
May 13 2005