Bug 23182 - gdb prints wrong contents of non-contiguous arrays
Summary: gdb prints wrong contents of non-contiguous arrays
Status: UNCONFIRMED
Alias: None
Product: gdb
Classification: Unclassified
Component: fortran (show other bugs)
Version: 8.1
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-05-15 08:37 UTC by richard.foltyn
Modified: 2018-09-07 12:13 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments
code to replicate the example given (183 bytes, text/x-fortran)
2018-05-15 08:37 UTC, richard.foltyn
Details

Note You need to log in before you can comment on or make changes to this bug.
Description richard.foltyn 2018-05-15 08:37:39 UTC
Created attachment 11017 [details]
code to replicate the example given

Hi,

gdb incorrectly prints the contents of array dummy arguments if the actual argument is a non-contiguous array section.

For example, using the demo in main.f90, when inspecting the array X in subroutine SUB1 in gdb, it prints
(gdb) p x
$1 = (( 1, 2) ( 3, 4) ( 5, 6) )

while the array contents printed using PRINT in that routine displays the correct values
1, 2, 4, 5, 7, 8
Comment 1 wytrzeszcz 2018-09-07 12:13:43 UTC
Hi, 
I'm looking for possible reason and I found  that print array itself can work properly but somehow 'x' and 'arr' has similar address. 

I run example code form attachment, add second similar print and pause in between of them 



(gdb) p *(&x)@2
$23 = (( ( 1, 2) ( 3, 4) ( 5, 6) ) ( ( 7, 8) ( 9, 0) ( 1286409216, 549739804) ) )
(gdb) p *(&arr)@2
$24 = (( ( 1, 2, 3) ( 4, 5, 6) ( 7, 8, 9) ) ( ( 0, 1286409216, 549739804) ( -8128, 32767, 1431655342) ( 21845, -7896, 32767) ) )
(gdb) p &arr
$25 = (PTR TO -> ( integer(kind=4) (3,3))) 0x7fffffffdff0
(gdb) p &x  
$26 = (PTR TO -> ( integer(kind=4) (2,3))) 0x7fffffffdff0