[fpc-devel] Variant assignment error
Alexander Todorov
alexx.todorov at gmail.com
Wed Jan 25 22:35:27 CET 2006
Hi to all,
When assigning string that represent numerical value to a variant and
after that assigning that variant to a numeric variable an exception
is raised. When debugging it shows the following message :
-------------------------------------------------------------------------------
EVarianterror
###(gdb unparsed remainder: s $0 out of bounds>)###)
-------------------------------------------------------------------------------
The error is for Int64 and Double types. Should I check for values
from other numerical types?
Here is the sample program.
------------------------------------------------
program project1;
{$mode objfpc}{$H+}
uses SysUtils, Variants;
var D : Double;
V : Variant;
I64 : Int64;
I : Integer;
begin
V := 150000000; //150 000 000
I := V;
writeln('integer - ', I);
V := IntToStr(150000000);
I := V; // <--- works
writeln('integer str - ', I);
V := 150000000000; // 150 000 000 000
I64 := V;
writeln('int64 - ', I64);
V := IntToStr(150000000000);
I64 := V; // <--- doesn't work FPC / Delphi 6
writeln('int64 str - ', I64);
V := 3.14;
D := V;
writeln('double - ', D);
V := FloatToStr(3.14);
D := V; // <--- doesn't work FPC. works in Delphi 6
writeln('double str - ', D);
end.
------------------------------------------------
Tested with FPC 2.0.1 on Windows XP. Should I add a bug report for that ?
More information about the fpc-devel
mailing list