Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2006-01

Variant assignment error

2 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Alexander Todorov

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 ?

Reply by email

Peter Vreman
to Alexander Todorov
Show quoted text 10 lines
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

Fixed

Reply by email