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

Debug issue for pointers to array slices #1224

Open
RichBarton-Arm opened this issue Feb 15, 2022 · 0 comments
Open

Debug issue for pointers to array slices #1224

RichBarton-Arm opened this issue Feb 15, 2022 · 0 comments
Assignees

Comments

@RichBarton-Arm
Copy link
Collaborator

flang generates incorrect debug info for the pointers to array slices in the below example.

> flang -g pointers.f90 -o pointers
> gdb ./pointers
> b pointers.f90:36
> run
Breakpoint 1, test () at pointers.f90:36
36      print *,"storage1 = ",storage1
> info locals
storage1 = (-2, -1, -8, -7, -7, -7, -7, -9, -1, -3)
pointer2 = (-5, -4, -11, -10, -10, -10)
storage2 = (-5, -4, -11, -10, -10, -10, -10, -12, -4, -6)
pointer1 = (-2, -1, -8, -7, -7, -7)

You can see that pointer1 and pointer2 are the right size, but are starting from index 1 in their target arrays and not index 3.

! pointers.f90
program test
!static storage
integer, dimension(10), target :: storage1

!pointer to storage1
integer, dimension(:), pointer :: pointer1

!dynamically allocated
integer, dimension(:), allocatable, target :: storage2

!pointer to storage2
integer, dimension(:), pointer :: pointer2

allocate(storage2(10))

storage1=-1
storage1(1)=-2
storage1(10)=-3

storage2=-4
storage2(1)=-5
storage2(10)=-6

pointer1=>storage1(3:8)

pointer2=>storage2(3:8)

pointer1=-7
pointer1(1)=-8
pointer1(6)=-9

pointer2=-10
pointer2(1)=-11
pointer2(6)=-12

print *,"storage1 = ",storage1
print *,"storage2 = ",storage2
print *,"pointer1 = ",pointer1
print *,"pointer2 = ",pointer2

write(*,*) 'end of program'

end
@vigbalu vigbalu self-assigned this Feb 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants