D - array declaration bug
- Pavel Minayev (4/4) Dec 24 2001 The following code (from WinAPI headers) doesn't compile:
- Lars Ivar Igesund (5/12) Mar 11 2004 This still don't work. The spec don't say anything about it, but
- =?ISO-8859-1?Q?Julio_Jim=E9nez?= (12/30) Mar 11 2004 Don't work?
- Lars Ivar Igesund (8/47) Mar 11 2004 Wrong circumstances. (My cancelled message was plain wrong, btw).
- =?ISO-8859-1?Q?Julio_Jim=E9nez?= (18/72) Mar 11 2004 Your last change:
- J C Calvarese (23/37) Mar 11 2004 It compiles for me (on WinXP Home), but it doesn't link (there's no main...
- Walter (33/38) Mar 11 2004 It works when I try it:
- =?ISO-8859-1?Q?Julio_Jim=E9nez?= (17/27) Mar 11 2004 void main()
- Lars Ivar Igesund (18/36) Mar 14 2004 I'm sorry about the fuzz here, but the bug is there somewhat.
- =?ISO-8859-1?Q?Julio_Jim=E9nez?= (18/60) Mar 14 2004 const int FOO = 100;
- Lars Ivar Igesund (4/77) Mar 14 2004 I accept this (and understand) but the error message imply that
- Russ Lewis (4/8) Mar 15 2004 I think that D is supposed to allow these types of forward declarations....
The following code (from WinAPI headers) doesn't compile: const int SIZE_OF_80387_REGISTERS = 80; ubyte[1 + SIZE_OF_80387_REGISTERS - 1] RegisterArea; It tells that "integer constant expression" is expected...
Dec 24 2001
Pavel Minayev wrote:The following code (from WinAPI headers) doesn't compile: const int SIZE_OF_80387_REGISTERS = 80; ubyte[1 + SIZE_OF_80387_REGISTERS - 1] RegisterArea; It tells that "integer constant expression" is expected...This still don't work. The spec don't say anything about it, but 'const int FOO = 1' is certainly an 'integer constant expression' in my eyes. Lars Ivar Igesund
Mar 11 2004
Lars Ivar Igesund wrote:Pavel Minayev wrote:Don't work? void main() { const int SIZE_OF_80387_REGISTERS = 80; ubyte[1 + SIZE_OF_80387_REGISTERS - 1] RegisterArea; printf("RegisterArea.size = %d\n", RegisterArea.size); } Output: RegisterArea.size = 80 DMD 0.81 for linux JulioThe following code (from WinAPI headers) doesn't compile: const int SIZE_OF_80387_REGISTERS = 80; ubyte[1 + SIZE_OF_80387_REGISTERS - 1] RegisterArea; It tells that "integer constant expression" is expected...This still don't work. The spec don't say anything about it, but 'const int FOO = 1' is certainly an 'integer constant expression' in my eyes. Lars Ivar Igesund
Mar 11 2004
Julio Jiménez wrote:Lars Ivar Igesund wrote:Wrong circumstances. (My cancelled message was plain wrong, btw). ---- array.d ------ const int FOO = 100; int[FOO] arr; ------------------- don't compile at all. Lars Ivar IgesundPavel Minayev wrote:Don't work? void main() { const int SIZE_OF_80387_REGISTERS = 80; ubyte[1 + SIZE_OF_80387_REGISTERS - 1] RegisterArea; printf("RegisterArea.size = %d\n", RegisterArea.size); } Output: RegisterArea.size = 80 DMD 0.81 for linux JulioThe following code (from WinAPI headers) doesn't compile: const int SIZE_OF_80387_REGISTERS = 80; ubyte[1 + SIZE_OF_80387_REGISTERS - 1] RegisterArea; It tells that "integer constant expression" is expected...This still don't work. The spec don't say anything about it, but 'const int FOO = 1' is certainly an 'integer constant expression' in my eyes. Lars Ivar Igesund
Mar 11 2004
Lars Ivar Igesund wrote:Julio Jiménez wrote:Your last change: void main() { const int SIZE_OF_80387_REGISTERS = 80; ubyte[1 + SIZE_OF_80387_REGISTERS - 1] RegisterArea; printf("RegisterArea.size = %d\n", RegisterArea.size); const int FOO = 100; int [FOO] arr; printf("arr.size = %d\n", arr.size); } Output: RegisterArea.size = 80 arr.size = 400 That's all right..... What dmd version do you have? regards JulioLars Ivar Igesund wrote:Wrong circumstances. (My cancelled message was plain wrong, btw). ---- array.d ------ const int FOO = 100; int[FOO] arr; ------------------- don't compile at all. Lars Ivar IgesundPavel Minayev wrote:Don't work? void main() { const int SIZE_OF_80387_REGISTERS = 80; ubyte[1 + SIZE_OF_80387_REGISTERS - 1] RegisterArea; printf("RegisterArea.size = %d\n", RegisterArea.size); } Output: RegisterArea.size = 80 DMD 0.81 for linux JulioThe following code (from WinAPI headers) doesn't compile: const int SIZE_OF_80387_REGISTERS = 80; ubyte[1 + SIZE_OF_80387_REGISTERS - 1] RegisterArea; It tells that "integer constant expression" is expected...This still don't work. The spec don't say anything about it, but 'const int FOO = 1' is certainly an 'integer constant expression' in my eyes. Lars Ivar Igesund
Mar 11 2004
Lars Ivar Igesund wrote:[...]Wrong circumstances. (My cancelled message was plain wrong, btw). ---- array.d ------ const int FOO = 100; int[FOO] arr; ------------------- don't compile at all.It compiles for me (on WinXP Home), but it doesn't link (there's no main). build.bat: echo off dmd array.d -c pause Output: Press any key to continue . . . If I add a main it compiles, links, and runs. array.d: const int FOO = 100; int[FOO] arr; void main() { printf("It works for me.\n"); } Output: d:\dmd\bin\..\..\dm\bin\link.exe array,,,user32+kernel32/noi; It works for me. Press any key to continue . . . HTHLars Ivar Igesund-- Justin http://jcc_7.tripod.com/d/
Mar 11 2004
"Lars Ivar Igesund" <larsivar igesund.net> wrote in message news:c2qj99$pvh$3 digitaldaemon.com...---- array.d ------ const int FOO = 100; int[FOO] arr; ------------------- don't compile at all.It works when I try it: ------------------------------- C:\cbx\mars>type test.d const int FOO = 100; int[FOO] arr; C:\cbx\mars>dmd -c test C:\cbx\mars>obj2asm test _TEXT segment dword use32 public 'CODE' ;size is 0 _TEXT ends _DATA segment para use32 public 'DATA' ;size is 4 _DATA ends CONST segment para use32 public 'CONST' ;size is 0 CONST ends _BSS segment para use32 public 'BSS' ;size is 400 _BSS ends FLAT group public _D4test3FOOi public _D4test3arrG100i _TEXT segment assume CS:_TEXT _TEXT ends _DATA segment _D4test3FOOi: db 064h,000h,000h,000h _DATA ends CONST segment CONST ends _BSS segment _BSS ends end C:\cbx\mars>
Mar 11 2004
Lars Ivar Igesund wrote:Sorry. I meant static arrays: const int FOO = 100; static int [FOO] arr; I also see that I don't need the static part, so I drop the charges. Lars Ivar Igesundvoid main() { const int SIZE_OF_80387_REGISTERS = 80; ubyte[1 + SIZE_OF_80387_REGISTERS - 1] RegisterArea; printf("RegisterArea.size = %d\n", RegisterArea.size); const int FOO = 100; static int [FOO] arr; printf("arr.size = %d\n", arr.size); } Output: RegisterArea.size = 80 arr.size = 400 It's ok.... ;-) (int size = 4 bytes) Regards Julio
Mar 11 2004
Lars Ivar Igesund wrote:Pavel Minayev wrote:I'm sorry about the fuzz here, but the bug is there somewhat. What I really did was this: ---------------------- array.d ---------------------- char [FOO] array; const int FOO = 100; int main() { return 0; } ---------------------- This don't compile with dmd 0.81 with the message "array.d(1): Integer constant expression expected instead of FOO" If I switch lines 1 and 2, it works. It's a bug IMHO but the workaround is simple. Lars Ivar IgesundThe following code (from WinAPI headers) doesn't compile: const int SIZE_OF_80387_REGISTERS = 80; ubyte[1 + SIZE_OF_80387_REGISTERS - 1] RegisterArea; It tells that "integer constant expression" is expected...This still don't work. The spec don't say anything about it, but 'const int FOO = 1' is certainly an 'integer constant expression' in my eyes. Lars Ivar Igesund
Mar 14 2004
Lars Ivar Igesund wrote:Lars Ivar Igesund wrote:const int FOO = 100; int main() { return 0; }Pavel Minayev wrote:I'm sorry about the fuzz here, but the bug is there somewhat. What I really did was this: ---------------------- array.d ----------------------char [FOO] array;The following code (from WinAPI headers) doesn't compile: const int SIZE_OF_80387_REGISTERS = 80; ubyte[1 + SIZE_OF_80387_REGISTERS - 1] RegisterArea; It tells that "integer constant expression" is expected...This still don't work. The spec don't say anything about it, but 'const int FOO = 1' is certainly an 'integer constant expression' in my eyes. Lars Ivar Igesundchar [FOO] array; const int FOO = 100; int main() { return 0; } ---------------------- This don't compile with dmd 0.81 with the message "array.d(1): Integer constant expression expected instead of FOO" If I switch lines 1 and 2, it works. It's a bug IMHO but the workaround is simple. Lars Ivar IgesundHe He..... You are trying to use FOO before define it..... ;-) change the lines order to.... const int FOO = 100; char [FOO] array; int main() { return 0; } and compiles ok regards again... Julio
Mar 14 2004
Julio Jiménez wrote:Lars Ivar Igesund wrote:I accept this (and understand) but the error message imply that the problem is something else than an undefined symbol. Lars Ivar IgesundLars Ivar Igesund wrote:const int FOO = 100; int main() { return 0; }Pavel Minayev wrote:I'm sorry about the fuzz here, but the bug is there somewhat. What I really did was this: ---------------------- array.d ----------------------char [FOO] array;The following code (from WinAPI headers) doesn't compile: const int SIZE_OF_80387_REGISTERS = 80; ubyte[1 + SIZE_OF_80387_REGISTERS - 1] RegisterArea; It tells that "integer constant expression" is expected...This still don't work. The spec don't say anything about it, but 'const int FOO = 1' is certainly an 'integer constant expression' in my eyes. Lars Ivar Igesundchar [FOO] array; const int FOO = 100; int main() { return 0; } ---------------------- This don't compile with dmd 0.81 with the message "array.d(1): Integer constant expression expected instead of FOO" If I switch lines 1 and 2, it works. It's a bug IMHO but the workaround is simple. Lars Ivar IgesundHe He..... You are trying to use FOO before define it..... ;-) change the lines order to.... const int FOO = 100; char [FOO] array; int main() { return 0; } and compiles ok regards again... Julio
Mar 14 2004
I think that D is supposed to allow these types of forward declarations. Certainly, it allows other types of forward declartions.... Russ Lars Ivar Igesund wrote:I accept this (and understand) but the error message imply that the problem is something else than an undefined symbol. Lars Ivar Igesund
Mar 15 2004