This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: Possible g77 bug
- From: bdavis <bdavis11 at directvinternet dot com>
- To: Mats Peterson <mats at snowbee dot dyns dot cx>
- Cc: gcc-bugs at gcc dot gnu dot org
- Date: 23 Dec 2002 17:27:58 -0600
- Subject: Re: Possible g77 bug
- References: <200212200131.gBK1VoAK021492@pc10.snowbee.foo>
The program does not conform to the F77 standard, thus it is not a bug.
You must test for EOF by checking the IOSTAT variable or by using the
"END=statement", not by using "ERR=statement".
Take a look at the ANSI X3.9-1978 FORTRAN language standard, it covers
this in some detail. Do a google search, copies are available on the
web.
regards,
bud davis
On Thu, 2002-12-19 at 19:31, Mats Peterson wrote:
> Hello.
>
> The code below doesn't work with g77 in either FreeBSD or Linux.
> Try pressing Control-D and watch it loop forever.
> It does work with the Compaq Fortran compiler.
>
> g77 version: GNU Fortran 0.5.25 20010315 (release)
> FreeBSD version: 4.6.2-RELEASE-p5
> Linux version: 2.4.18
>
> ---------------------------------------------------------
>
> PROGRAM TEST
> 10 READ (UNIT=*, FMT=*, IOSTAT=NERR, ERR=100) N
> PRINT *, 'You entered ', N
> GO TO 10
> 100 IF (NERR .LT. 0) THEN
> PRINT *, 'EOF'
> STOP
> ENDIF
> PRINT *, 'Invalid input'
> GO TO 10
> END
>
> ---------------------------------------------------------
>
> Regards,
> Mats Peterson
>