Free Pascal does not comply with the ISO 7185 Standard at level 1

Original Reporter info from Mantis: juancdiaz
  • Reporter name: Juan Díaz

Description:

While Free Pascal almost fully complies with the ISO 7185 Standard at level 0 (there is still a bug related to the use of the GET procedure when reaching the end-of-file mark), it is not compliant with this Standard at level 1.
Level 1 requires the compiler to support conformant-array parameters (Pascal ISO 7185:1990 document, page 4).
In the Free Pascal Programmer's Guide, Programmer's Guide for Free Pascal, Version 3.2.0, Document version 3.2.0, February 2020, it says on page 158, when referring to the ISO mode of the compiler: "In this mode, the compiler complies with the requirements of level 0 and level 1 of ISO/IEC 7185."
Notwithstanding, when trying to compile the example code given on page 114 of the Pascal User Manual and Report, fourth edition, a syntax error is reported and the compiation process is aborted:

fpc -Miso MatrixMul2.pas

Free Pascal Compiler version 3.2.0 [2020/06/04] for i386
Copyright (c) 1993-2020 by Florian Klaempfl and others
Target OS: Win32 for i386
Compiling MatrixMul2.pas
MatrixMul2.pas(15,35) Fatal: Syntax error, "OF" expected but "[" found
Fatal: Compilation aborted
Error: C:\FPC\3.2.0\bin\i386-Win32\ppc386.exe returned an error exitcode

Furthermore, the code that follows won't compile either.

program TestLevel1(output);

type natural = 1..maxint;
     string5 = packed array [1..5] of char;
     string15 = packed array [1..15] of char;
     string20 = packed array [1..20] of char;

var s5: string5;
      s15: string15;
      s20: string20;
      V1, V2, Sum: array [1..3] of real;
      k: 1..3;

procedure writestring(var s: packed array [lo..hi: natural] of char);
   var i: natural;
begin
   for i := lo to hi do
      write(s[i])
end {writestring} ;

procedure sumvectors(var A, B, C: array [lo..hi: natural] of real);
   var i: natural;
begin
   for i := lo to hi do
      C[i] := A[i] + B[i]
end {sumvectors} ;    

begin
   s5 := 'Hello';
   s15 := 'Standard Pascal';
   writeln;
   writestring(s5);
   write(', ');
   writestring(s15);
   writeln;
   for k := 1 to 3 do 
   begin
      V1[k] := k * 0.5;
      V2[k] := k * 10.5
   end ;
   sumvectors(V1, V2, Sum);
   s20 := 'Summing two vectors:';
   writeln; 
   writestring(s20);
   writeln;
   writeln('V1' :10, 'V2' :10, 'Sum' :10);
   for k := 1 to 3 do
   begin
      write(V1[k] :10:1, V2[k] :10:1, Sum[k] :10:1);
      writeln
   end
end .

fpc -Miso TestLevel1.pas

Free Pascal Compiler version 3.2.0 [2020/06/04] for i386
Copyright (c) 1993-2020 by Florian Klaempfl and others
Target OS: Win32 for i386
Compiling TestLevel1.pas
TestLevel1.pas(14,30) Error: Type identifier expected
TestLevel1.pas(14,30) Fatal: Syntax error, ")" expected but "PACKED" found
Fatal: Compilation aborted
Error: C:\FPC\3.2.0\bin\i386-Win32\ppc386.exe returned an error exitcode

Therefore, the statement in the Free Pascal Programmer's Guide about Free Pascal being compliant with the ISO 7185 Standard at level 1 is misleading.
I sincerely hope the Free Pascal team will take the necessary measures to ensure the compiler's full compliance with the ISO 7185 Standard at both level 0 and level 1.

Steps to reproduce:

Download the attached file, TestLevel1.pas, and compile it in ISO mode at the command line:

fpc -Miso TestLevel1.pas

Mantis conversion info:

  • Mantis ID: 38632
  • OS: Windows 7
  • Platform: i386
  • Version: 3.2.0
  • Monitored by: » @KaMiSchi (Karl-Michael Schindler)