https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115057

            Bug ID: 115057
           Summary: TextIO.ReadRestLine raise an exception for
                    insufficient buffer
           Product: gcc
           Version: 15.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: modula2
          Assignee: gaius at gcc dot gnu.org
          Reporter: dramwang at 163 dot com
  Target Milestone: ---

For following code, `ReadRestLine` will raise an "attempting to read beyond end
of file" exception, which I think is incorrect:

```
MODULE test ;

IMPORT SeqFile, TextIO ;

VAR
  chan : SeqFile.ChanId ;
  line : ARRAY [0..5] OF CHAR ;
  results : SeqFile.OpenResults ;

BEGIN
  SeqFile.OpenRead (chan, "test.mod", SeqFile.read, results) ;
  TextIO.ReadRestLine (chan, line) ;
END test.
```

Tested on Debian 12, with GCC 15.0.0 20240509 (83fb5e6):

```
% gm2 test.mod && ./a.out
EXCEPTIONS.mod:65:56: In RAISE
EXCEPTIONS.mod:65:56:attempting to read beyond end of file
Aborted
```

Reply via email to