[fpc-devel] Optimization -O2 on Linux AMD64

petr.kristan at epos.cz petr.kristan at epos.cz
Thu Jul 10 19:05:36 CEST 2008


Hi.

Today i was hunting malicious error.

System: AMD64 Linux, fpc from svn rev 11355.

program o2;

uses
  sysutils;

function MSecsToTimeStamp(MSecs: comp): TTimeStamp;
begin
  result.Date := Trunc(msecs / msecsperday);
  msecs:= msecs-comp(result.date)*msecsperday;
  writeln(result.Date); //732067
  result.Time := Round(MSecs);
  writeln(result.Date); //0
end ;

begin
  MSecsToTimeStamp(63250588800000);
end.

Compiled with optimization: fpc -S2 -O2 o2.pas
Result is:
732067
0
and should be
732067
732067

This occurs only on Linux AMD64. Linux i386, win32 and win64 is ok.

Problem is, that rtl (sysutils) is compiled with -O2 implicitly.

Petr

-- 
Ing. Petr Kristan
.
EPOS PRO s.r.o., Bozeny Nemcove 2625, 530 02 Pardubice
tel: +420 466335223    Czech Republic (Eastern Europe) 
fax: +420 466510709



More information about the fpc-devel mailing list