Thread overview | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
December 24, 2001 array declaration bug | ||||
---|---|---|---|---|
| ||||
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... |
March 11, 2004 [BUG] Re: array declaration bug | ||||
---|---|---|---|---|
| ||||
Posted in reply to Pavel Minayev | 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
|
March 11, 2004 Re: [BUG] Re: array declaration bug | ||||
---|---|---|---|---|
| ||||
Posted in reply to Lars Ivar Igesund | Lars Ivar Igesund wrote:
> 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
>
>
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
Julio
|
March 11, 2004 Re: [BUG] Re: array declaration bug | ||||
---|---|---|---|---|
| ||||
Posted in reply to Julio Jiménez | Julio Jiménez wrote:
> Lars Ivar Igesund wrote:
>
>> 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
>>
>>
>
> 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
>
>
> Julio
>
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 Igesund
|
March 11, 2004 Re: [BUG] Re: array declaration bug | ||||
---|---|---|---|---|
| ||||
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 Igesund
>
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;
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
|
March 11, 2004 Re: [BUG] Re: array declaration bug | ||||
---|---|---|---|---|
| ||||
Posted in reply to Lars Ivar Igesund | Lars Ivar Igesund wrote:
> Julio Jiménez wrote:
>
>> Lars Ivar Igesund wrote:
>>
>>> 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
>>>
>>>
>>
>> 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
>>
>>
>> Julio
>>
>
> 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 Igesund
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
Julio
|
March 12, 2004 Re: [BUG] Re: array declaration bug | ||||
---|---|---|---|---|
| ||||
Posted in reply to Lars Ivar Igesund | 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 . . . HTH > > Lars Ivar Igesund -- Justin http://jcc_7.tripod.com/d/ |
March 12, 2004 Re: [BUG] Re: array declaration bug | ||||
---|---|---|---|---|
| ||||
Posted in reply to Lars Ivar Igesund | "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> |
March 14, 2004 Re: [BUG] Re: array declaration bug | ||||
---|---|---|---|---|
| ||||
Posted in reply to Lars Ivar Igesund | Lars Ivar Igesund wrote:
> 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
>
>
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 Igesund
|
March 14, 2004 Re: [BUG] Re: array declaration bug | ||||
---|---|---|---|---|
| ||||
Posted in reply to Lars Ivar Igesund | Lars Ivar Igesund wrote: > Lars Ivar Igesund wrote: > >> 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 >> >> > > 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; } > 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 Igesund He 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 |
Copyright © 1999-2021 by the D Language Foundation