[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: gm2 rejecting a constant statement as variable
From: |
Gaius Mulley |
Subject: |
Re: gm2 rejecting a constant statement as variable |
Date: |
Sun, 31 Mar 2024 15:07:29 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) |
Alice Osako <alicetrillianosako@gmail.com> writes:
> I ran into another issue which I am less certain about. The following
> declaration
>
> VAR
> powerOf2 : ARRAY [0..Bitwidth-1] OF CARDINAL;
>
> Gives the following error:
>
> src/imp/CardMath.mod:374:14: error: In procedure ‘IntMaxDecDigitsTable’:
> circular dependency error found when trying to resolve array
> 374 | powerOf2 : ARRAY [0..Bitwidth-1] OF CARDINAL;
> | ^~~~~
>
> What is peculiar here is that a) the declarations of powerOf2 and Bitwidth
> are not circular, and b) this declaration is of module scope, and comes
> before the
> beginning of IntMaxDecDigitsTable. For reference, Bitwidth is a constant
> defined as
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> MaxCardDivPow2Of8 = MAX(CARDINAL) DIV 256;
> MaxCardDivPow2Of16 = MaxCardDivPow2Of8 DIV 256;
> MaxCardDivPow2Of24 = MaxCardDivPow2Of16 DIV 256;
> MaxCardDivPow2Of32 = MaxCardDivPow2Of24 DIV 256;
> MaxCardDivPow2Of40 = MaxCardDivPow2Of32 DIV 256;
> MaxCardDivPow2Of48 = MaxCardDivPow2Of40 DIV 256;
> MaxCardDivPow2Of56 = MaxCardDivPow2Of48 DIV 256;
> MaxCardDivPow2Of64 = MaxCardDivPow2Of56 DIV 256;
> MaxCardDivPow2Of72 = MaxCardDivPow2Of64 DIV 256;
> MaxCardDivPow2Of80 = MaxCardDivPow2Of72 DIV 256;
> MaxCardDivPow2Of88 = MaxCardDivPow2Of80 DIV 256;
> MaxCardDivPow2Of96 = MaxCardDivPow2Of88 DIV 256;
> MaxCardDivPow2Of104 = MaxCardDivPow2Of96 DIV 256;
> MaxCardDivPow2Of112 = MaxCardDivPow2Of104 DIV 256;
> MaxCardDivPow2Of120 = MaxCardDivPow2Of112 DIV 256;
>
> BW8 = (MAX(CARDINAL) <= 255);
> BW16 = (MaxCardDivPow2Of8 > 0) AND (MaxCardDivPow2Of8 <= 255);
> BW24 = (MaxCardDivPow2Of16 > 0) AND (MaxCardDivPow2Of16 <= 255);
> BW32 = (MaxCardDivPow2Of24 > 0) AND (MaxCardDivPow2Of24 <= 255);
> BW40 = (MaxCardDivPow2Of32 > 0) AND (MaxCardDivPow2Of32 <= 255);
> BW48 = (MaxCardDivPow2Of40 > 0) AND (MaxCardDivPow2Of40 <= 255);
> BW56 = (MaxCardDivPow2Of48 > 0) AND (MaxCardDivPow2Of48 <= 255);
> BW64 = (MaxCardDivPow2Of56 > 0) AND (MaxCardDivPow2Of56 <= 255);
> BW72 = (MaxCardDivPow2Of64 > 0) AND (MaxCardDivPow2Of64 <= 255);
> BW80 = (MaxCardDivPow2Of72 > 0) AND (MaxCardDivPow2Of72 <= 255);
> BW88 = (MaxCardDivPow2Of80 > 0) AND (MaxCardDivPow2Of80 <= 255);
> BW96 = (MaxCardDivPow2Of88 > 0) AND (MaxCardDivPow2Of88 <= 255);
> BW104 = (MaxCardDivPow2Of96 > 0) AND (MaxCardDivPow2Of96 <= 255);
> BW112 = (MaxCardDivPow2Of104 > 0) AND (MaxCardDivPow2Of104 <= 255);
> BW120 = (MaxCardDivPow2Of112 > 0) AND (MaxCardDivPow2Of112 <= 255);
> BW128 = (MaxCardDivPow2Of120 > 0) AND (MaxCardDivPow2Of120 <= 255);
>
> Bitwidth =
> 8*ORD(BW8) + 16*ORD(BW16) + 24*ORD(BW24) + 32*ORD(BW32) +
> 40*ORD(BW40) + 48*ORD(BW48) + 56*ORD(BW56) + 64*ORD(BW64) +
> 72*ORD(BW72) + 80*ORD(BW80) + 88*ORD(BW88) + 96*ORD(BW96) +
> 104*ORD(BW104) + 112*ORD(BW112) + 120*ORD(BW120) + 128*ORD(BW128);
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> where BWn is a series of boolean values which gate individual bit markers
> (AFAICT, anyway).
>
> I can't see how these declarations would be circular.
I suspect this bug will disappear once the constant expression relop bug
has been fixed (or is related). Currently the compiler is creating a
temporary variable to store the result of the relop (which it thinks
will be known at runtime) - but this conflicts with the declaration of
the array needed at compiletime.