Optimizer is far too aggressive
Original Reporter info from Mantis: Jasper
-
Reporter name: Jasper Neumann
Original Reporter info from Mantis: Jasper
- Reporter name: Jasper Neumann
Description:
When running the following program
program calltest;
var
count: integer;
procedure nop;
begin
end;
function f():cardinal;
begin
inc(count);
result:=count;
end;
begin
count:=0;
if f()=1 then
nop;
if f()=-1 then
nop;
if f()=2 then
nop;
if f()<>-1 then
nop;
system.writeln(count);
end.
some calls to f() are optimized away but must remain even if the expression is always false or always true.
At the end of the program count must be 4 (as in Delphi).
The problem seems to be independent of the optimize settings.
Mantis conversion info:
- Mantis ID: 17838
- Build: 16304
- Platform: win32,win64
- Fixed in version: 3.0.0
- Fixed in revision: 18275 (#c855c7a0)
- Monitored by: » luizamerico (Luiz Americo)