On Sun, 29 Jul 2012, Phillip Helbig wrote:
> Date: Sun, 29 Jul 2012 19:08:54 +0200
> From: Phillip Helbig <[log in to unmask]>
> Reply-To: Fortran 90 List <[log in to unmask]>
> To: [log in to unmask]
> Subject: Can anyone reproduce this bug?
>
> I've found a strange error in Compaq Fortran V7.5-2630-48C8L under VMS
> 7.3-2 on ALPHA. Not the newest version, but some replies from usenet
> indicated a completely different compiler shows the same bug, if indeed
> it is a bug, which is rather bizarre.
>
> This does not produce an error:
>
> MODULE BLA
> INTEGER :: I=RADIX(1)
> END MODULE BLA
> PROGRAM TEST
> USE BLA, ONLY: I, RADIX
> PRINT*, I
> END PROGRAM TEST
>
> However, this does:
>
> MODULE BLA
> INTEGER :: I=RADIX(I)
> END MODULE BLA
> PROGRAM TEST
> USE BLA, ONLY: I, HUGE
> PRINT*, I
> END PROGRAM TEST
>
> And this does as well:
>
> MODULE BLA
> INTEGER :: I=RADIX(I)
> END MODULE BLA
> PROGRAM TEST
> USE BLA, ONLY: I, FJWEIFJOIW
> PRINT*, I
> END PROGRAM TEST
>
> In both cases:
>
> %F90-E-ERROR, Name in only-list does not exist.
>
> which is what I would expect.
>
> In other words, if the ONLY list contains a name which is the same as
> the name of a function used in a specification statement in the
> corresponding module, then no error occurs during compilation. However,
> this is just a bogus object; one can't do anything with it:
>
> PRINT*, I, RADIX
> ...........^
> %F90-E-ERROR, This name has already been used as an intrinsic function
> name. [RADIX]
>
> So the compiler knows it is not a variable. It is not declared in the
> module, merely used there like one can use intrinsic functions in
> specification expressions.
>
> These are just examples. It seems to be a general thing: if the ONLY
> list contains a name which is the same as the name of a function used in
> a specification statement in the corresponding module, then no error
> occurs.
>
> What is going on here?
>
NAG Fortran does warn about the first of those programs at compile time:
Warning: testonly1.f90, line 7: RADIX explicitly imported into TEST but
not used
[NAG Fortran Compiler normal termination, 1 warning]
But with the last, including PRINT*, I, RADIX it says at compile time
Error: testonly4.f90, line 6: Procedure name RADIX in i/o list
[NAG Fortran Compiler error termination, 1 error]
That error message is quite right. So is Compaq's. You can't print a
procedure name, only a valid expression, e.g. RADIX(1).
What surprised me was that three different compilers let me print
RADIX(). Either that is allowed by the Fortran standard or it's
disallowed but happens to violate no Constraint, so compilers are not
obliged to complain about it.
-- John Harper, School of Mathematics Statistics and Operations Research
Victoria University, PO Box 600, Wellington 6140, New Zealand
e-mail [log in to unmask] phone (+64)(4)463 5276 fax (+64)(4)463 5045
|