[Converted from Gnats 936] GDB is not able to show array, which bounds are variable. Fragment of debug information dump (it is generated by Intel compiler): <2><11a>: Abbrev Number: 5 (DW_TAG_variable) DW_AT_decl_line : 3 DW_AT_decl_column : 9 DW_AT_decl_file : 1 DW_AT_accessibility: 1 (public) DW_AT_name : b DW_AT_type : <181> DW_AT_location : 2 byte block: 75 70 ( DW_OP_breg5: -16) DW_AT_external : 0 ................................. <2><147>: Abbrev Number: 6 (DW_TAG_variable) DW_AT_accessibility: 1 (public) DW_AT_name : .tdbg.0 DW_AT_artificial : 1 DW_AT_type : <c9> DW_AT_location : 2 byte block: 75 68 ( DW_OP_breg5: -24) DW_AT_external : 0 <2><15a>: Abbrev Number: 6 (DW_TAG_variable) DW_AT_accessibility: 1 (public) DW_AT_name : .tdbg.1 DW_AT_artificial : 1 DW_AT_type : <c9> DW_AT_location : 2 byte block: 75 6c ( DW_OP_breg5: -20) DW_AT_external : 0 .......................... <1><181>: Abbrev Number: 10 (DW_TAG_array_type) DW_AT_sibling : <198> DW_AT_type : <c9> DW_AT_data_location: 2 byte block: 97 6 ( DW_OP_push_object_address DW_OP_deref) <2><18d>: Abbrev Number: 11 (DW_TAG_subrange_type) DW_AT_upper_bound : <147> <2><192>: Abbrev Number: 11 (DW_TAG_subrange_type) DW_AT_upper_bound : <15a> Example of debug session: This GDB was configured as "i686-pc-linux-gnu"... (gdb) b 7 Breakpoint 1 at 0x8048b1f: file vla1.c, line 7. (gdb) b 14 Breakpoint 2 at 0x8048bfc: file vla1.c, line 14. (gdb) r Starting program: /home1/sana/trackers/GDB/tr28427/a.out Breakpoint 1, foo (dim1=2, dim2=4, arr=0xbffff828) at vla1.c:7 7 for (i=0; i < dim2; i++) (gdb) p %ebp -16 A parse error in expression, near `ebp -16'. (gdb) p $ebp -16 $1 = (void *) 0xbffff7f8 (gdb) x /2 0xbffff7f8 0xbffff7f8: 0xbffff7c0 0x00000000 (gdb) x /10 0xbffff7c0 0xbffff7c0: 0x08048508 0x40022000 0x40022778 0xbffff80c 0xbffff7d0: 0x4000d2b6 0x080484c8 0x40016998 0x00000001 0xbffff7e0: 0x00000008 0x00000020 (gdb) c Continuing. b [0][0] = 0 address b [0][0] = 0xbffff7c0 b [0][1] = 10 address b [0][1] = 0xbffff7c4 b [1][0] = 1 address b [1][0] = 0xbffff7c8 b [1][1] = 11 address b [1][1] = 0xbffff7cc b [2][0] = 2 address b [2][0] = 0xbffff7d0 b [2][1] = 12 address b [2][1] = 0xbffff7d4 b [3][0] = 3 address b [3][0] = 0xbffff7d8 b [3][1] = 13 address b [3][1] = 0xbffff7dc Breakpoint 2, foo (dim1=2, dim2=4, arr=0xbffff828) at vla1.c:14 14 return j; (gdb) x /10 0xbffff7c0 0xbffff7c0: 0x00000000 0x0000000a 0x00000001 0x0000000b 0xbffff7d0: 0x00000002 0x0000000c 0x00000003 0x0000000d 0xbffff7e0: 0x00000008 0x00000020 (gdb) As debug session demonstrates debug information for 'b' is correct. Example of debug session if executable file is built by GCC: This GDB was configured as "i686-pc-linux-gnu"... (gdb) b 7 Breakpoint 1 at 0x80484e9: file vla1.c, line 7. (gdb) b 14 Breakpoint 2 at 0x80485a8: file vla1.c, line 14. (gdb) r Starting program: /home1/sana/trackers/GDB/tr28427/gcc.out Breakpoint 1, foo (dim1=2, dim2=4, arr=0xbffff820) at vla1.c:7 7 for (i=0; i < dim2; i++) (gdb) whatis b type = int [2][2] (gdb) ptype b type = int [2][2] (gdb) p b $1 = {{-1073743968, -1073743936}, {8, 64}} (gdb) Release: unknown Environment: 32-bin && 64-bit Linux How-To-Repeat: Test is attached or below: int foo(int dim1, int dim2, int arr[2][4]) { int b[dim2][dim1]; int i,j; for (i=0; i < dim2; i++) for (j=0; j < dim1; j++){ b[i][j] = arr[j][i]; printf ("b [%d][%d] = %d\n", i, j, b[i][j]); printf ("address b [%d][%d] = %p\n", i, j, &(b[i][j])); } return j; } int main() { int b[2][4]; int i,j; for (i=0; i < 2; i++) for (j=0; j < 4; j++) b[i][j] = i*10+j; foo(2,4, b); } Intel compiler should be used for reproducing of problem. Command line is 'icc -g vla1.c'. Command line is icc -g vla1.c.
This is fixed now.