[fpc-devel]Incorrect warning msg using 'not' and 'DWord' (FPC 1.0.4)
jonas at zeus.rug.ac.be
Wed Mar 21 15:15:35 CET 2001
On Wednesday, March 21, 2001, at 02:20 PM, Jonas wrote:
> You can use
> cTest1 = DWord($03);
> However, I think support for this was only introduced after 1.0.4. It is accepted in
> previous versions, but the type cast is ignored. I found out that for some reason even in the
> current version it still gives a warning when using this, but I'm debugging that right now.
I only implemented that functionality in 1.1 it seems. I've now added it to 1.0.5 as well, and now there are no warnings anymore there.
It doesn't compile under 1.1 though (when using -Cr). The reason is that in 1.0.x, currently the result of not(constant) is always a longint (= sizeof(constant_expressions)), except when the argument is a cardinal (then the result is also a cardinal).
In 1.1 however, the resulttype of not(constant) = resulttype of the constant itself. Also, constants held in int64's there, instead of in longints. This means you get
not(cardinal(3)) = $ffff ffff ffff fffc
which then is implicitely converted to a cardinal (since the resulttype of not is defined as being the same as that of the argument) and as such gives a range check error. We can fix this similarly as in 1.0.x by changing the resulttype of not(constant) to int64 (except when the argument is a qword, then the result will also be a qword), but I don't know if that is a satisfactory solution.
More information about the fpc-devel