View Issue Details

IDProjectCategoryView StatusLast Update
0037320FPCCompilerpublic2020-07-10 22:41
ReporterScott Franco Assigned ToFlorian  
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionno change required 
OSWindows 
Product Version3.2.0 
Fixed in Version3.3.1 
Summary0037320: Fails on ISO 7185 dispose
DescriptionFails to allow ISO 7185 use of tagfield constants on dispose.

I have included the run from two other compilers to show the correct behavior, as well as the source (test.pas).
Steps To ReproduceC:\projects\PASCAL\pascal-p5>fpc -Miso test.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 test.pas
test.pas(10,14) Fatal: Syntax error, ")" expected but "," found
Fatal: Compilation aborted
Error: C:\FPC\3.2.0\bin\i386-Win32\ppc386.exe returned an error exitcode

C:\projects\PASCAL\pascal-p5>type test.pas
program test;

type r = record case b: boolean of false: (i: integer); true: (c: char) end;

var rp: ^r;

begin

   new(rp, true);
   dispose(rp, true)

end.

C:\projects\PASCAL\pascal-p5>gpc --classic-pascal-level-0 test.pas
test.pas: In main program:
test.pas:10: warning: tag fields ignored in `Dispose'

C:\projects\PASCAL\pascal-p5>p5 test

Compiling and running test

P5 Pascal compiler vs. 1.4.x
Pascal-P5 complies with the requirements of level 0 of ISO/IEC 7185.


     1 -32 program test;
     2 -32
     3 -32 type r = record case b: boolean of false: (i: integer); true: (c: char) end;
     4 -32
     5 -32 var rp: ^r;
     6 -32
     7 -32 begin
     8 3
     9 3 new(rp, true);
    10 10 dispose(rp, true)
    11 15
    12 15 end.

Errors in program: 0
P5 Pascal interpreter vs. 1.4.x

Assembling/loading program
Running program


program complete

C:\projects\PASCAL\pascal-p5>
Additional InformationPlease note current ISO 7185 acceptance test is at:

https://sourceforge.net/p/pascalp5/code/ci/master/tree/standard_tests/iso7185pat.pas

Thanks.
TagsNo tags attached.
Fixed in Revision
FPCOldBugId
FPCTarget-
Attached Files

Relationships

related to 0037085 resolvedFlorian In ISO mode, Dispose with multiple parameters is not yet implemented. 
related to 0037322 resolvedFlorian ISO 7185 mode rejects program name as duplicate 
related to 0037323 resolvedFlorian Does not recognize ISO 7185 standard label 

Activities

Scott Franco

2020-07-09 17:58

reporter   ~0123846

In iso7185pat.pas (referred to above), matching new() and dispose tags are present in the test as record30 and record31 tests. This tests for the above issue.

However, there are several other issues with the test:

C:\projects\PASCAL\pascal-p5>fpc -Miso standard_tests\iso7185pat.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 standard_tests\iso7185pat.pas
iso7185pat.pas(462,15) Error: Duplicate identifier "iso7185pat"
iso7185pat.pas(888,7) Warning: unreachable code
iso7185pat.pas(917,43) Warning: unreachable code
iso7185pat.pas(920,18) Warning: unreachable code
iso7185pat.pas(926,18) Warning: unreachable code
iso7185pat.pas(982,12) Error: Identifier not found "4"
iso7185pat.pas(982,15) Error: identifier isn't a label
iso7185pat.pas(984,10) Error: Label used but not defined "4"
iso7185pat.pas(984,10) Fatal: Syntax error, "UNTIL" expected but "identifier WRITELN" found
Fatal: Compilation aborted
Error: C:\FPC\3.2.0\bin\i386-Win32\ppc386.exe returned an error exitcode

I believe the FPC group passed this test previously (iso7185pat.pas), however, the test gets updated with new ISO 7185 tests on occasion.

Running down the list I see:

iso7185pat.pas(462,15) Error: Duplicate identifier "iso7185pat"

The name of the program is not supposed to preclude use of the name within the program (this comes from the BSI test suite).

iso7185pat.pas(982,12) Error: Identifier not found "4"
iso7185pat.pas(982,15) Error: identifier isn't a label
iso7185pat.pas(984,10) Error: Label used but not defined "4"
iso7185pat.pas(984,10) Fatal: Syntax error, "UNTIL" expected but "identifier WRITELN" found

Yea, this one really sucks. Its also new (and I believe also comes from the BSI test suite). The failing test is:

   write('Control18: start ');
   repeat(*comment(*comment*)
      goto 004;
      write('!! BAD !!');
      4: writeln('stop s/b start stop');
      i := 0;
      if i <> 0 then goto 04;
   until true;

And the original label declaration is:

label
      0, 3, 9999, 0004;

IE., all different numbers of leading zeros for label "4". ISO 7185 says the label is supposed to be identified by "its apparent numerical value", not its spelling.

You certainly have my sympathy on that one. I'll file it as a separate bug.

Cyrax

2020-07-09 18:00

reporter   ~0123847

Can you test FPC trunk? It should be fixed in it, see this bug report https://bugs.freepascal.org/view.php?id=37085

Marco van de Voort

2020-07-09 22:36

manager   ~0123856

Last edited: 2020-07-09 23:17

View 2 revisions

Can confirm the dispose test in the report body works with trunk.

The problems with the rest of the test (mainprogram identifier reuse, and numeric value of the label still exist)

It also seems this revision merges cleanly.

Scott Franco

2020-07-10 06:01

reporter   ~0123861

So to be captain obvious here, the dispose tag constants don't do anything on any implementation that I know of. Traditionally they are ignored, since the heap manager knows how big the space being returned is (usually an arena header). An implementation that simply accepts them or skips them is compliant. Pascal-P5 has an option that actually verifies that they are the same as what was given in new(), in order to check against standard requirements, which is that they specify the same VARIANTS as new does. This is actually tricky, since:

type
subrange = 1..3;
r = record case s: subrange of 1, 2: (i: integer); 3: (c: char) end;

var rp: ^r;

begin

   new(rp, 1);
   dispose(rp, 2)

end;

is valid, since both specify the same variant.

Scott Franco

2020-07-10 06:03

reporter   ~0123862

PS the duplicate program name and goto label issue I filed new bugs for.

Florian

2020-07-10 22:41

administrator   ~0123873

The tagfield stuff is already fixed in trunk so I close this one as the two other issues are reported separately as well.

Issue History

Date Modified Username Field Change
2020-07-09 17:34 Scott Franco New Issue
2020-07-09 17:58 Scott Franco Note Added: 0123846
2020-07-09 18:00 Cyrax Note Added: 0123847
2020-07-09 22:36 Marco van de Voort Note Added: 0123856
2020-07-09 22:37 Marco van de Voort Relationship added related to 0037085
2020-07-09 23:17 Marco van de Voort Note Edited: 0123856 View Revisions
2020-07-10 06:01 Scott Franco Note Added: 0123861
2020-07-10 06:03 Scott Franco Note Added: 0123862
2020-07-10 22:41 Florian Assigned To => Florian
2020-07-10 22:41 Florian Status new => resolved
2020-07-10 22:41 Florian Resolution open => no change required
2020-07-10 22:41 Florian Fixed in Version => 3.3.1
2020-07-10 22:41 Florian FPCTarget => -
2020-07-10 22:41 Florian Note Added: 0123873
2020-07-10 22:41 Florian Relationship added related to 0037322
2020-07-10 22:41 Florian Relationship added related to 0037323