[fpc-devel] Re: fpc-devel Digest, Vol 99, Issue 3

Max Nazhalov stein_nospam at mail.ru
Thu Jul 5 13:48:24 CEST 2012


On Tue Jul 3 17:46:58 CEST 2012 Marcel M?rtens wrote:

> Hello,
> i think i've found a bug in the procedure TryStrtoFloat.
> To get this bug, create a new project and run this lines (i'm using a
> button to run the line, but it shouldn't matter)

> ---------------------------------------------------
> var
>    areal:real;
> begin
> TryStrtoFloat('86E6722INVALID!',areal);
> end;
> ---------------------------------------------------

> "86E6722" is a valid number, which is out of range and creates an error.
> The whole text is not a valid number, but it also creates an error.
> It raises an "External: SIGFPE" error.

> B.t.w.:  "TryStrToInt('86E6722INVALID!',aint);"  or
> "TryStrToInt('86E6722',aint);" raises no error, they just return false.

Confirmed. r21354, Win32.

EOverflow: Floating point overflow
  $00404BF1  fpc_val_real_shortstr,  line 1484 of C:/prog/FPC_SRC/rtl/inc/sstrings.inc
  ...

Quick investigation showed the following:

source line #1484: fpc_Val_Real_ShortStr:=fpc_Val_Real_ShortStr*hd
here: "fpc_Val_Real_ShortStr" is 8.6000000000000000E+4931, and "hd" is 1.00000000000000000E+1792

Surely, You should file this case to Mantis.

BTW, reverting r20705 ("{ Calculate Exponent }" section) fixes the problem on x86, but possibly introduces problems on other platforms (see r20705 description)..

Alternate way is to mask overflow exception within fpc_Val_Real_ShortStr, I suspect.

-- 
Best regards,
 Max




More information about the fpc-devel mailing list