[fpc-devel] fpc 2.0.1 and 2.1.1 behave differently

Peter Vreman peter at freepascal.org
Wed Oct 5 10:54:05 CEST 2005


> Hi,
>
> The following compiles with fpc 2.0.1, but not anymore with fpc 2.1.1.
>
> Is it a bug in my code (and fpc 2.0.1) or in fpc 2.1.1?
>
> program Project1;
>
> {$mode objfpc}{$H+}
>
> procedure test(l: longint);
> begin
> end;
>
> begin
>    test(longint(''));
> end.

You are dependning on the internal storage of constant strings. In 2.0.1
it is an ansistring because of the $H+, compiling with $H- gives an error.
Because an ansistring is 4 bytes in 32bit the explicit typeconversion to a
4 bytes longint will work in 32bit mode.

In 2.1.1 constant strings are array[0..x] of char. Where only a
longint('1234') can be converted.








More information about the fpc-devel mailing list