Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[flang] Definitions of an array using subscript triplet of derived type is incorrect #62038

Closed
ohno-fj opened this issue Apr 10, 2023 · 4 comments
Assignees
Labels
bug Indicates an unexpected problem or unintended behavior flang:ir

Comments

@ohno-fj
Copy link

ohno-fj commented Apr 10, 2023

Version of flang-new : 17.0.0(633146093c4ea78dc8f56a27006fe4eed84be370)

Definitions of an array using subscript triplet of derived type are incorrect.

The following definitions are not correctly applied:

  v(1:2)%a(2,3)=2

There is no problem if you change the definition as follows:

  v(1)%a(2,3)=2
  v(2)%a(2,3)=2

The following are the test program, results of Flang-new, GFortran and ifort compilation and execution.

snggp155_4.f90:

subroutine sub
  type x
     integer, DIMENSION(2, 3) :: a
  end type x
  type(x),target::v(3)
  v(1)%a=3; v(2)%a=3; v(1:2)%a(2,3)=2

  write(6,*) "v(1)%a           = ", v(1)%a
  write(6,*) "v(2)%a           = ", v(2)%a
  write(6,*) "v(1:2)%a(2, 3)   = ", v(1:2)%a(2, 3)
  write(6,*) "v(1)%a(2, 3)     = ", v(1)%a(2, 3)
  write(6,*) "v(2)%a(2, 3)     = ", v(2)%a(2, 3)

end subroutine sub

program main
  call sub
end program main
$ flang-new -flang-experimental-exec snggp155_4.f90; ./a.out
 v(1)%a           =  3 3 3 3 2 3
 v(2)%a           =  3 3 3 3 2 3
 v(1:2)%a(2, 3)   =  2 2
 v(1)%a(2, 3)     =  3
 v(2)%a(2, 3)     =  3
$
$ gfortran snggp155_4.f90; ./a.out
 v(1)%a           =            3           3           3           3           3           2
 v(2)%a           =            3           3           3           3           3           2
 v(1:2)%a(2, 3)   =            2           2
 v(1)%a(2, 3)     =            2
 v(2)%a(2, 3)     =            2
$
$ ifort snggp155_4.f90; ./a.out
 v(1)%a           =            3           3           3           3           3
           2
 v(2)%a           =            3           3           3           3           3
           2
 v(1:2)%a(2, 3)   =            2           2
 v(1)%a(2, 3)     =            2
 v(2)%a(2, 3)     =            2
$
@EugeneZelenko EugeneZelenko added flang Flang issues not falling into any other category and removed new issue labels Apr 10, 2023
@psteinfeld psteinfeld added the bug Indicates an unexpected problem or unintended behavior label Jun 2, 2023
@llvmbot
Copy link
Collaborator

llvmbot commented Jun 2, 2023

@llvm/issue-subscribers-bug

@luporl
Copy link
Contributor

luporl commented Jun 26, 2023

Issue also happens when built with flang-new -flang-experimental-hlfir.

@luporl luporl self-assigned this Jun 27, 2023
@luporl
Copy link
Contributor

luporl commented Jun 30, 2023

@llvmbot
Copy link
Collaborator

llvmbot commented Jun 30, 2023

@llvm/issue-subscribers-flang-ir

@EugeneZelenko EugeneZelenko removed the flang Flang issues not falling into any other category label Jun 30, 2023
@luporl luporl closed this as completed in 783222e Jul 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Indicates an unexpected problem or unintended behavior flang:ir
Development

No branches or pull requests

5 participants