[fpc-devel] Wrong computations with -CfSSE -O3 options

Stefan Berinde sberinde at math.ubbcluj.ro
Tue Jun 12 22:53:35 CEST 2007


Hi,

Following program should output 100, but it does 0.
It seems to be a bug.
Some incompatibilities between optimization switches,
or something else?

Stefan



program bug;

function Func(a:longint): longint;
begin
 if (a >= 0) then Func:=Trunc(1.0*a) else Func:=-Trunc(1.0*a);
end;

begin
 Writeln(Func(100));
end.

==========================

Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

D:\Research\Coding\bug>fpc.exe -CfSSE -O3 bug.pas
Free Pascal Compiler version 2.1.4 [2007/05/11] for i386
Copyright (c) 1993-2007 by Florian Klaempfl
Target OS: Win32 for i386
Compiling bug.pas
Linking bug.exe
9 lines compiled, 0.1 sec, 23312 bytes code, 1160 bytes data

D:\Research\Coding\bug>bug.exe
0




More information about the fpc-devel mailing list