8000 Possibly non-standard behavior on explicit re-declaration of a variable that was previously implicitly typed · Issue #6459 · lfortran/lfortran · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Possibly non-standard behavior on explicit re-declaration of a variable that was previously implicitly typed #6459
Open
@difference-scheme

Description

@difference-scheme

Here's a truly weird one, that I found in an old random number generator.

The Fortran standard appears to allow the following, strange, explicit "re-declaration" of a variable, that was already declared with the same type by means of implicit typing:

subroutine random( )

  implicit real(kind=8) (a-h,o-z), integer(kind=4) (i-n)

  save luxlev

  integer(kind=4) ::  luxlev                                        

end subroutine random

I don't know what the standard truly says regarding such cases, but both gfortran, ifx, and flang-20 compile the above code without any complaints. Whereas compiling this with lfortran -c --implicit-typing random.f90 gives:

semantic error: Symbol is already declared in the same scope
 --> random.f90:7:24
  |
7 |    integer(kind=4) ::  luxlev                                        
  |                        ^^^^^^ redeclaration
  |
5 |    save luxlev
  |         ~~~~~~ original declaration

You may wish to investigate this, because I am truly at a loss here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0