Skip to content

[Flang] Incorrect execution result when procedure statement and generic statement are declared with a different procedure-name and a different generic-spec in two type-bound procedures #115673

@ohno-fj

Description

@ohno-fj
Version of flang-new : 20.0.0(74b56c7eb807e2ba54bd7a2bcfda5d0bceff1c0c)/AArch64

When procedure statement (binding-name => procedure-name) and generic statement (generic-spec => binding-name-list) are declared with a different procedure-name and a different binding-name-list in two type-bound procedures (ty_21 and ty_4), the result is not correct.
The expected value of the variable (n) is 21.

The following are the test program, Flang-new, Gfortran and ifx compilation/execution result.

sngg787n_22.f90:

module m4
  type :: ty_21
   contains
     procedure, private,nopass :: p21=>proc_21
     generic                   :: gen_name=>p21
  end type ty_21
contains
  subroutine proc_21(c)
    character c
    write(1,*)21
  end subroutine proc_21
end module m4

module m6
  use m4
  type, extends(ty_21) :: ty_4
   contains
     generic                   :: gen_name=>p45
     procedure, private,nopass :: p21=>proc_42
     procedure, private,nopass :: p45=>proc_45
  end type ty_4
contains
  subroutine proc_45(h)
    complex(16) ::h
    write(1,*)80
  end subroutine proc_45
  subroutine proc_42(c)
    character c
    write(1,*)44
  end subroutine proc_42
end module m6

program main
  use m6
  type(ty_4) :: v
  call v%gen_name('1')
  rewind 1
  read(1,*) n
  if (n/=21) print *,100144,n
  write(6,*) "n = ", n
  print *,'pass'
  close(1,STATUS="DELETE")
end program main
$ flang-new sngg787n_22.f90; ./a.out
 100144 44
 n =  44
 pass
$
$ gfortran sngg787n_22.f90; ./a.out
      100144          44
 n =           44
 pass
$
$ ifx sngg787n_22.f90; ./a.out
 n =           21
 pass
$

Metadata

Metadata

Assignees

No one assigned

    Labels

    flangFlang issues not falling into any other categoryquestionA question, not bug report. Check out https://llvm.org/docs/GettingInvolved.html instead!

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions