digitalmars.D.bugs - DMD-0.123 introduced bug
- Andrew Fedoniouk (15/15) May 13 2005 Following:
- Walter (3/18) May 13 2005 static Two[12] Twos;
- Andrew Fedoniouk (18/29) May 13 2005 I know, but suppose I have (close to real situation)
- Thomas Kuehne (11/37) May 14 2005 -----BEGIN PGP SIGNED MESSAGE-----
- Stewart Gordon (29/44) May 16 2005 AIUI the point the OP is making is that the error message makes no sense...
- Andrew Fedoniouk (14/36) May 16 2005 In fact I do not understand this statement in doc.
- Stewart Gordon (13/28) May 17 2005 The first sentence of that paragraph is arrays in general. *Then* it
- Thomas Kuehne (11/14) May 17 2005 -----BEGIN PGP SIGNED MESSAGE-----
- Stewart Gordon (11/23) May 18 2005 Just thinking about it, it depends on which side of the contradiction
-
Stewart Gordon
(10/13)
May 18 2005
- Walter (4/8) May 18 2005 This doesn't compile because now the compiler detects that it would over...
- Jarrett Billingsley (9/10) May 13 2005 This is really the line that's causing the problem (looks like another f...
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
"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
"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...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.Following: struct Two // <<<<<<<<<<<<< { int i; } static Two[12] Twos = [];static Two[12] Twos;
May 13 2005
-----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...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-----"Andrew Fedoniouk" <news terrainformatica.com> wrote in message news:d63bn0$11v$1 digitaldaemon.com...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.Following: struct Two // <<<<<<<<<<<<< { int i; } static Two[12] Twos = [];static Two[12] Twos;
May 14 2005
Thomas Kuehne wrote:-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Andrew Fedoniouk schrieb am Fri, 13 May 2005 21:46:04 -0700:<snip>"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...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>static Two[12] Twos = [];static Two[12] Twos;Added to DStress as http://dstress.kuehne.cn/run/a/array_initialization_15.dShould 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
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>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 otherwiseAdded to DStress as http://dstress.kuehne.cn/run/a/array_initialization_15.dShould 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."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
Andrew Fedoniouk wrote: <snip>The first sentence of that paragraph is arrays in general. *Then* it goes on to talk about arrays that parallel enums."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<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
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Stewart Gordon schrieb am Mon, 16 May 2005 11:35:35 +0100: <snip><snip>What would be the correct error message for array_initialization_15? Thomas -----BEGIN PGP SIGNATURE----- iD8DBQFCii7c3w+/yD4P9tIRAq8sAKDS72PgqCE36CIq44TGnMNVXB4wlACgvhTI RisGfqtqWPDtbki98MoKm0g= =9Uao -----END PGP SIGNATURE-----Added to DStress as http://dstress.kuehne.cn/run/a/array_initialization_15.dShould be nocompile. The bug is a bad error line number.
May 17 2005
Thomas Kuehne wrote:-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Stewart Gordon schrieb am Mon, 16 May 2005 11:35:35 +0100: <snip><snip>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.What would be the correct error message for array_initialization_15?Added to DStress as http://dstress.kuehne.cn/run/a/array_initialization_15.dShould be nocompile. The bug is a bad error line number.
May 18 2005
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
"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
"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