Spurious warnings about unreachable code with iso mode and mod operator
Original Reporter info from Mantis: svat
-
Reporter name: Shreevatsa R
Original Reporter info from Mantis: svat
- Reporter name: Shreevatsa R
Description:
The following example is minimized from a larger example (trying to compile some old programs of Donald Knuth). I needed the "{$mode iso}" so that the type "integer" uses a 32-bit integer. With that, I get several incorrect warnings about unreachable code, wherever the code uses the "mod" operator.
Here is an example, say test.pas:
{$mode iso}
program GLUE(input, output);
procedure printint(n: integer);
begin
repeat
writeln(n mod 10);
n := n div 10;
until n = 0;
end;
begin
printint(23);
writeln();
end.
The result of running "fpc test.pas" is:
Free Pascal Compiler version 3.0.4 [2018/10/02] for x86_64
Copyright (c) 1993-2017 by Florian Klaempfl and others
Target OS: Darwin for x86_64
Compiling test.pas
test.pas(7,15) Warning: unreachable code
Assembling (pipe) test.s
Linking test
(etc.)
The binary works fine, it's just that there's an incorrect warning about code that is obviously reachable.
Steps to reproduce:
-
Create a file test.pas with the above contents (or see attached).
-
Run "fpc test.pas"
-
Look for warnings.
Additional information:
Mantis conversion info:
- Mantis ID: 35897
- Build: x86_64
- Version: 3.0.4
- Fixed in version: 3.3.1