case statement in ISO mode is no longer standards compliant.
Original Reporter info from Mantis: Thaddy
-
Reporter name: Thaddy de Koning
Original Reporter info from Mantis: Thaddy
- Reporter name: Thaddy de Koning
Description:
The case statement is {$mode iso} is no longer compliant with ISO7185 and throws an error when compiled without an else clause.
Steps to reproduce:
Example from the case statement in the ISO7185:1990 document.
____________________________________________________________________
program isobug(infile,outfile);
{$mode iso}
{ ISO7185:1990
6.8.3.5 Case-statements
The values denoted by the case-constants of the case-constant-lists of the case-list-elements of a
case-statement shall be distinct and of the same ordinal-type as the expression of the case-index
of the case-statement . On execution of the case-statement the case-index shall be evaluated . That
value shall then specify execution of the statement of the case-list-element closest-containing the
case-constant denoting that value . One of the case-constants shall be equal to the value of the
case-index upon entry to the case-statement; otherwise, it shall be an error.
NOTE |Case-constants are not the same as statement labels.
case-statement = `case' case-index `of' case-list-element
f `;' case-list-element g [ `;' ] `end' .
case-list-element = case-constant-list ` :' statement .
case-index = expression .
Example:}
type
operator = (plus, minus, times, divide);
var
x:integer;
begin
x:=1;
case operator of
plus : x := x;
minus : x := x;
times : x := x;
end;
end.
Outputs:
Free Pascal Compiler version 3.3.1-r42526 [2019/07/29] for arm
Copyright (c) 1993-2018 by Florian Klaempfl and others
(1002) Target OS: Linux for ARMHF
(3104) Compiling isobug.pas
2 136/1.024 Kb Used
isobug.pas(24,17) Error: (6059) Case statement does not handle all possible cases
isobug.pas(32) Fatal: (10026) There were 1 errors compiling module, stopping
Fatal: (1018) Compilation aborted
Error: /usr/local/bin/ppcarm returned an error exitcode
Compilation failed.
Additional information:
This is a fairly recent change. It breaks all ISO complaint code that has case statements. It should at most generate a warning, but not an error.
If it is a requirement for extended pascal (I don think so!) please make it a modeswitch. This hurts a lot.
The above program is a compilable version of the example in the ISO7185:1990 standards document.
Mantis conversion info:
- Mantis ID: 35905
- OS: all
- OS Build: all supported
- Build: 42526
- Platform: all
- Version: 3.3.1
- Monitored by: » @KaiBurghardt (Kai Burghardt)