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] Incorrect execution result of initializing an array using vector subscript #62039

Closed
ohno-fj opened this issue Apr 10, 2023 · 3 comments
Assignees

Comments

@ohno-fj
Copy link

ohno-fj commented Apr 10, 2023

Version of flang-new : 17.0.0(633146093c4ea78dc8f56a27006fe4eed84be370)

The character array a1(1) is initialized with uppercase letters, but printed with lowercase letters.
a2(1) and a3(1) are correct.

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

z01.f90:

program main
  character(len=30),parameter:: a1(1)=(/&
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"/)

  character(len=30),parameter:: a2(1)=(/&
&"ABCDEFGHIJKLMNOPQRSTUVWXYZ"/)

  character(len=30),parameter:: a3(1)=(/"ABCDEFGHIJKLMNOPQRSTUVWXYZ"/)

  write(6,*) "a1(1) = ", a1(1)
  write(6,*) "a2(1) = ", a2(1)
  write(6,*) "a3(1) = ", a3(1)
end program main
$ flang-new -flang-experimental-exec z01.f90; ./a.out
 a1(1) = abcdefghijklmnopqrstuvwxyz
 a2(1) = ABCDEFGHIJKLMNOPQRSTUVWXYZ
 a3(1) = ABCDEFGHIJKLMNOPQRSTUVWXYZ
$
$ gfortran z01.f90; ./a.out
 a1(1) = ABCDEFGHIJKLMNOPQRSTUVWXYZ
 a2(1) = ABCDEFGHIJKLMNOPQRSTUVWXYZ
 a3(1) = ABCDEFGHIJKLMNOPQRSTUVWXYZ
$
$ ifort z01.f90; ./a.out
 a1(1) = ABCDEFGHIJKLMNOPQRSTUVWXYZ
 a2(1) = ABCDEFGHIJKLMNOPQRSTUVWXYZ
 a3(1) = ABCDEFGHIJKLMNOPQRSTUVWXYZ
$
@EugeneZelenko EugeneZelenko added flang Flang issues not falling into any other category and removed new issue labels Apr 10, 2023
@luporl
Copy link
Contributor

luporl commented May 29, 2023

Reduced test:

program main
  character(len=3) :: a =&
"ABC"

  print *, a
end program main

Interestingly, if a space is added between = and & or before the string literal then the issue doesn't occur.

@luporl luporl self-assigned this May 29, 2023
@luporl
Copy link
Contributor

luporl commented Jun 1, 2023

Patch: https://reviews.llvm.org/D151885

@EugeneZelenko EugeneZelenko added flang:frontend and removed flang Flang issues not falling into any other category labels Jun 1, 2023
@llvmbot
Copy link
Collaborator

llvmbot commented Jun 1, 2023

@llvm/issue-subscribers-flang-frontend

@luporl luporl closed this as completed in 0e1fa91 Jun 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

4 participants