floating point exception leads to access violation
Original Reporter info from Mantis: BeniBela @benibela
-
Reporter name: Benito van der Zander
Original Reporter info from Mantis: BeniBela @benibela
- Reporter name: Benito van der Zander
Description:
After several floating point exceptions, I get an access violation
Steps to reproduce:
This works without error:
var s, sr: single;
i, j, tempcode: Integer;
begin
Val('8.077936E-28', sr, tempcode);
for i := 1 to 5000 do begin
s := 0;
try
for j := 0 to Random(5) do s += Random(2) * power(2, Random(256) - 127);
except
on e: EMathError do s := 0; //continue;
end;
end;
Val('8.077936E-28', sr, tempcode);
end.
This prints EOverflow: Floating point overflow
var s, sr: single;
i, j, tempcode: Integer;
begin
for i := 1 to 5000 do begin
s := 0;
try
for j := 0 to Random(5) do s += Random(2) * power(2, Random(256) - 127);
except
on e: EMathError do s := 0; //continue;
end;
Val('8.077936E-28', sr, tempcode);
end;
end.
This prints EAccessViolation: Access violation
procedure test(const s: single);
var
tempcode: integer;
sr: single;
begin
Val('8.077936E-28', sr, tempcode);
if sr <> s then
end;
var s, sr: single;
i, j, tempcode: Integer;
begin
for i := 1 to 5000 do begin
s := 0;
try
for j := 0 to Random(5) do s += Random(2) * power(2, Random(256) - 127);
except
on e: EMathError do s := 0; //continue;
end;
test(s)
end;
end.
Additional information:
Perhaps it is related to #37468 (closed) ?
Mantis conversion info:
- Mantis ID: 37926
- OS: linux
- OS Build: opensuse
- Build: r47006
- Platform: amd64
- Version: 3.3.1
- Target version: 3.2.2