Sign in Join

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

Mailing lists / fpc-devel / 2007-06

Wrong computations with -CfSSE -O3 options

1 message · 1 person ·

Reply by email Subscribe to this list Your subscription

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

Stefan Berinde

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

Reply by email