Re: whole number constants
  Home FAQ Contact Sign in
comp.lang.fortran only
 
Advanced search
POPULAR GROUPS

more...

 Up
Re: whole number constants         

Group: comp.lang.fortran · Group Profile
Author: Michael Prager
Date: Jul 24, 2008 07:21

Thomas Koenig wrote:
> I guess it is time to bring up the old example of the "variation of
> constants", which used to work with the IBM compiler on MVS/ESA
> the last time I tried it out (maybe 20 years ago):
>
> PROGRAM MAIN
> CALL SUB(3)
> PRINT *,3
> END
> SUBROUTINE SUB(I)
> I = 4
> END
>
> This printed " 4", and, I hasten to add, is a fine example of what
> *not* to do. Compile this program with gfortran on Linux, and
> it segfaults on execution.

Other results....

Compiled on Windows with Intel Fortran, with either default
options or /check:all, the program fails with an access
violation.

Compiled with g95 (default options or -Wall), the program prints
3. (There may be better checking options for g95, but I can't
find them.)

Compiled on with Lahey LF95 and no checking options, the program
prints 4. (Close enough to WWIII for me.) With checking turned
on, Lahey prints the most informative error message:

There is an assignment to dummy argument 1, which is associated
with a constant, an expression that is not a variable, do
variable or variable with intent(in) attribute actual argument.
Error occurs at or near line 5 of _sub_
Called from or near line 2 of _MAIN__

--
Mike Prager, NOAA, Beaufort, NC
Address spam-trapped; remove color to reply.
* Opinions expressed are personal and not represented otherwise.
* Any use of tradenames does not constitute a NOAA endorsement.
no comments
diggit! del.icio.us! reddit!