[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Issue with constant
From: |
Gaius Mulley |
Subject: |
Re: Issue with constant |
Date: |
Sun, 06 Nov 2022 14:00:29 +0000 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) |
Runar Tenfjord <runar.tenfjord@gmail.com> writes:
> The following code does not compile:
>
> MODULE test;
> FROM libc IMPORT printf;
>
> CONST
> MAXVALUE = 0FFFFFFFFFFFFFFFFH;
>
> VAR
> bigval : LONGCARD;
> BEGIN
> bigval := MAX(LONGCARD);
> printf('bigval = %llx\n', bigval); (* Prints 'bigval = fffffffffffffff'
> *)
> (* Assignment below fails *)
> bigval := MAXVALUE;
> printf('bigval = %llx\n', bigval);
> END test.
>
> The constant should be identical to MAX(LONGCARD) as printed,
> so this should probably work.
>
> Best regards
> Runar Tenfjord
Hi Runar,
yes - thanks for the report - quite correct. I will fix this and add a
regression test to ensure this does not happen again !
$ gm2 -g assign.mod
assign.mod:13:12: warning: attempting to assign a value ‘MAXVALUE’ to a
designator ‘bigval’ which will exceed the range of type ‘LONGCARD’
13 | bigval := MAXVALUE;
| ~~~~~~~^~~~~~~~~~~
regards,
Gaius