This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: possible bug in fortran compiler
- To: Luca BOTTURA <Botturl at mt dot msm dot cern dot ch>
- Subject: Re: possible bug in fortran compiler
- From: Toon Moene <toon at moene dot indiv dot nluug dot nl>
- Date: Wed, 17 Jun 98 21:09:01 +0200
- Cc: egcs-bugs at cygnus dot com
- Organization: Moene Computational Physics, Maartensdijk, The Netherlands
- References: <199806160803.KAA11526@dxmint.cern.ch>
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.