arm linux, problem with optimization -O2
Original Reporter info from Mantis: Bernd
-
Reporter name: Bernd
Original Reporter info from Mantis: Bernd
- Reporter name: Bernd
Description:
The compiler seems to generate wrong code for the following program, when it is compiled with -O2 for arm linux.
Program Test;
{$mode objfpc}{$H+}
function ldexp( x: Real; N: Integer):Real;
{* ldexp() multiplies x by 2**n. *}
var r : Real;
begin
R := 1;
if N>0 then
while N>0 do
begin
R:=R*2;
Dec(N);
end
else
while N<0 do
begin
R:=R/2;
Inc(N);
end;
ldexp := x * R;
end;
var
z, y: Real;
begin
z:= 4;
y:= 4;
z:= y - ldexp( z, 4 );
writeln(z); { should be -60, but is 4 with -O2 }
end.
Compiler parameter: ppcrossarm -O2 test.pas
The code is part of genmath.inc and leads to wrong values for sine and cosine when the rtl is compiled with -O2.
Mantis conversion info:
- Mantis ID: 10863
- Build: stable version
- Platform: arm linux
- Version: 2.2.0
- Fixed in version: 2.2.2
- Fixed in revision: 10713 (#35f7ba89)
- Monitored by: » Alex_Lutovinin (Alex_Lutovinin)
- Target version: 2.2.2