possible bug in fortran compiler

Toon Moene toon@moene.indiv.nluug.nl
Wed Jun 17 13:01:00 GMT 1998


Luca,

>  The following simple fortran code compiled in egcs
>  (egcs-2.90.22 971220 (egcs-1.01 beta)) :
>
>        integer I
>        read(5,*) I
>        stop
>        end
>
>  would not generate an error code if the variable read is
>  in real format (i.e. 123.45 would be read 123 without
>  error generated). This is (I think) an anomalous behaviour
>  that is not common to other fortran compilers.

The Standard says:

10.8.1 List-directed input

...
When the next effective item [ of the list of variables on the read  
statement ] is of type integer, the value in the input record is  
interpreted as if an Iw edit descriptor with a suitable value of w [  
width in characters ] were used.
...


10.5.1.1 integer editing

....
In the input field for the I edit descriptor, the character string  
shall be a signed-digit-string (R401), except for the interpretation  
of blanks [ not relevant here ]
...

A signed-digit-string is simply a sign (+ or -) followed by a  
non-zero number of digits.  So the integer input field simply stops  
at the `.'.  Now, if you would have read *more* items from the input  
line than just the single integer, you would have gotten an error.

HTH,
Toon.



More information about the Gcc-bugs mailing list