View Issue Details

IDProjectCategoryView StatusLast Update
0037415FPCRTLpublic2020-09-16 09:26
ReporterKarl-Michael Schindler Assigned ToFlorian  
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
PlatformdarwinOSMac OS X 
Product Version3.3.1 
Fixed in Version3.3.1 
Summary0037415: iso-mode: reset a data file gives a run time error.
DescriptionThe following program gives a runtime error, when compiled in iso mode.

program fileTest(dat);

var
  dat: file of integer;
begin
  reset(dat);
end.

Running fileTest on MacOS results in:

FileTest iso mode> ./fileTest
Runtime error 2 at $000000010634DB22
  $000000010634DB22
Steps To Reproducefpc -Miso fileTest.pas
./fileTest
Additional InformationNo problem, when using a text-file instead of a data-file.

In case of a fix, can it please be also applied to 3.2-fixes?
TagsNo tags attached.
Fixed in Revision46865
FPCOldBugId
FPCTarget-
Attached Files

Activities

Florian

2020-07-24 22:36

administrator   ~0124311

So you expect that dat is assigned to input in this case?

Kai Burghardt

2020-07-25 00:05

reporter   ~0124313

If there’s any confusion: What Karl-Michael does is actually correct, confer the `program copy` as in § 6.10 “Programs” of ISO 7185: https://pascal-central.com/iso7185.html#6.10%20Programs

However, `dat` is not supposed to become `input`. I think the explanations given in ISO 10206 § 6.12 “Main-program declarations” are more enlightening.

Karl-Michael Schindler

2020-07-25 01:34

reporter   ~0124318

As Kai said, dat does not become input. In case of reads and writes, input and output would be required. My example is a stripped down version without read and write. Therefore, I stripped input, output. In a real world example the program statement would probably be 'program fileTest (input, output, dat);' I did a brief test of this. It fails the same way.

Karl-Michael Schindler

2020-07-25 01:44

reporter   ~0124319

With a textfile, it works:

program fileTest(dat);
var dat: text;
begin
  reset(dat);
end.

jamie philbrook

2020-07-25 02:10

reporter   ~0124320

aren't you suppose to first Assignfile(dat, 'AFileNAme'); first ?
 
Var
 Dat:File of Integer;
Begin
  InoutRes := 0;
{$I-}
  AssignFile(Dat,'???????');
  Reset(Dat);
 if IoResult <> 0 Then
    Rewrite(Dat);
/…..

 I don't know maybe someone is over looking that..?:

 In Text Mode it most likely defaults to the input or output..

Kai Burghardt

2020-07-25 05:45

reporter   ~0124322

No, not Assign/AssignFile. That’s Delphi.

The ISO standards don’t actually define how to associate a `file` type variable with a file name, or – in general – with an object in the file system. They say it’s “implementation-defined”, so we’re sort of free to do whatever we like, we may even say it’s AssignFile in /our/ Pascal implementation.

Nevertheless, in Extended Pascal it’s rather bind(…). In ISO 10206 there’s an _example_ in § 6.7.6.8 “Binding functions”.
Then, however, `dat` should be declared `bindable`, confer https://www.gnu-pascal.de/gpc/File-Routines.html#File-Routines

Karl-Michael Schindler

2020-09-15 17:19

reporter   ~0125551

Last edited: 2020-09-15 17:27

View 3 revisions

I am afraid, 46865 did not do the job completely. The test example has a textfile with integers, but it should be a binary file of integer. In line with this, the test program tw37415.pp fails, but works if the file has binary integers.
Also, the directive { %FILES=DAT_TW37415 } does not seem to work even with the binary file, at least on macOS. I haven't tried other platforms.

Florian

2020-09-15 18:25

administrator   ~0125552

- the test example needs only a file with some data (ascii is also binary integers), so I added just a file with some data, so how does it fail?
- the %files directory is only something for the test suite runner to notify that the run of this test requires this file
- what happens on macOS if a file DAT_TW37415 (note the upper case!) exists? I tested on linux and it works.

Karl-Michael Schindler

2020-09-15 18:56

reporter   ~0125553

ok. mea culpa. I did not test cleanly. If the file is not present, it correctly gives Runtime error 2, if it is too short (tested with a modified version), it gives Runtime error 100.
Thanks for the clarification of the %files directive and sorry for the fuss. Please reset the issue to resolved and fixed.

Karl-Michael Schindler

2020-09-15 19:00

reporter   ~0125554

Last edited: 2020-09-15 19:00

View 2 revisions

any chance to back port it to 3.2-fixes?

Florian

2020-09-15 23:24

administrator   ~0125559

Thanks for the feedback.

Karl-Michael Schindler

2020-09-16 09:26

reporter   ~0125567

Thanks for your work.

Issue History

Date Modified Username Field Change
2020-07-24 13:45 Karl-Michael Schindler New Issue
2020-07-24 22:36 Florian Note Added: 0124311
2020-07-25 00:05 Kai Burghardt Note Added: 0124313
2020-07-25 01:34 Karl-Michael Schindler Note Added: 0124318
2020-07-25 01:44 Karl-Michael Schindler Note Added: 0124319
2020-07-25 02:10 jamie philbrook Note Added: 0124320
2020-07-25 05:45 Kai Burghardt Note Added: 0124322
2020-09-14 22:17 Florian Assigned To => Florian
2020-09-14 22:17 Florian Status new => resolved
2020-09-14 22:17 Florian Resolution open => fixed
2020-09-14 22:17 Florian Fixed in Version => 3.3.1
2020-09-14 22:17 Florian Fixed in Revision => 46865
2020-09-14 22:17 Florian FPCTarget => -
2020-09-15 17:19 Karl-Michael Schindler Status resolved => feedback
2020-09-15 17:19 Karl-Michael Schindler Resolution fixed => open
2020-09-15 17:19 Karl-Michael Schindler Note Added: 0125551
2020-09-15 17:22 Karl-Michael Schindler Note Edited: 0125551 View Revisions
2020-09-15 17:27 Karl-Michael Schindler Note Edited: 0125551 View Revisions
2020-09-15 18:25 Florian Note Added: 0125552
2020-09-15 18:56 Karl-Michael Schindler Note Added: 0125553
2020-09-15 18:56 Karl-Michael Schindler Status feedback => assigned
2020-09-15 19:00 Karl-Michael Schindler Note Added: 0125554
2020-09-15 19:00 Karl-Michael Schindler Note Edited: 0125554 View Revisions
2020-09-15 23:24 Florian Status assigned => resolved
2020-09-15 23:24 Florian Resolution open => fixed
2020-09-15 23:24 Florian Note Added: 0125559
2020-09-16 09:26 Karl-Michael Schindler Status resolved => closed
2020-09-16 09:26 Karl-Michael Schindler Note Added: 0125567