[fpc-devel] Broken frac function in FPC3.1.1 / Windows x86_64

info at wolfgang-ehrhardt.de info at wolfgang-ehrhardt.de
Wed Apr 25 11:04:21 CEST 2018

If you compile and run this 64-bit program on Win 64 you get a crash

program tfrac;
   x,y: double;
   x := 1e20;
   y := frac(x);

D:\Work\DAMath>D:\FPC311\bin\i386-win32\ppcrossx64.exe tfrac.pas
Free Pascal Compiler version 3.1.1-r20:38794 [2018/04/22] for x86_64
Copyright (c) 1993-2018 by Florian Klaempfl and others
Target OS: Win64 for x64
Compiling tfrac.pas
Linking tfrac.exe
9 lines compiled, 0.1 sec, 37472 bytes code, 2036 bytes data

x= 1.0000000000000000E+020
Runtime error 207 at $0000000100001BD0

I recently posted an issue to the bugtracker


But the only responses are by a reporter named Thaddy de Koning, which
are for me totally useless and IMO he did miss the point.

Are there changes to the frac function (or its documentation) in the
newer 64-bit windows cross-compiler? Especially for the allowed ranges?

This would not be intuitive because the corresponding int function works as
expected, and meanwhile I use the work-around  frac(x) := int(x) -x

Wolfgang Ehrhardt

More information about the fpc-devel mailing list