info-gnu-fortran
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: handling of duplicate declarations


From: Nelson H. F. Beebe
Subject: Re: handling of duplicate declarations
Date: Tue, 8 May 2007 08:26:18 -0600 (MDT)

I just tried Johnson Wu's test program with redundant variable
declarations (after fixing it to ensure that statements start after
column 6) with several Fortran compilers, both GNU and native ones,
with these results:

        The DEC Alpha f77 compiler produces a warning, but its f90 and
        f95 compiles abort with an error.

        The Portland Group pgf77, pghpf, and hpf90 compilers produce a
        warning, but compile.

        The GNU g77 and gfortran compilers abort with an error.

        The Intel ifort compiler aborts with an error.

        The PathScale f90 and f95 compilers produce warnings.

        The SGI IRIX MIPS f77 and f90 compilers accept the code
        without warnings.

        The Sun f77, f90, and f95 compilers on Solaris and GNU/Linux
        accept the code without warnings.

The Fortran 77 Standard does not appear to specify whether duplicate
declarations (of the same type) are permitted.  The Fortran 90
Standard is similarly unclear, although the Fortran 95 Handbook (Adams
et al) says on p. 103: ``An entry must not be given any attribute more
than once in a scoping unit'' (an attribute means, among other things,
a type).

I conclude that duplicate declarations are both redundant and
nonportable, and thus, should be strictly avoided.

-------------------------------------------------------------------------------
- Nelson H. F. Beebe                    Tel: +1 801 581 5254                  -
- University of Utah                    FAX: +1 801 581 4148                  -
- Department of Mathematics, 110 LCB    Internet e-mail: address@hidden  -
- 155 S 1400 E RM 233                       address@hidden  address@hidden -
- Salt Lake City, UT 84112-0090, USA    URL: http://www.math.utah.edu/~beebe/ -
-------------------------------------------------------------------------------




reply via email to

[Prev in Thread] Current Thread [Next in Thread]