http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45765
Summary: const array elements should be also const Product: gcc Version: 4.6.0 Status: UNCONFIRMED Severity: minor Priority: P3 Component: debug AssignedTo: unassig...@gcc.gnu.org ReportedBy: jan.kratoch...@redhat.com Target: x86_64-unknown-linux-gnu DWARF4 section 5.2 - the misformatter subsection "Type Modifier Entries" says: When multiple type modifiers are chained together to modify a base or user-defined type, the tree ordering reflects the semantics of the applicable lanuage rather than the textual order in the source presentation. And it seems to me that element `array[0]' from `const type array[1]' should be really DW_TAG_const itself, not just to inherit `const' from the array. I am not 100% sure it is right DWARF explanation. [patch] const array types From: Ken Werner <ken at linux dot vnet dot ibm dot com> http://sourceware.org/ml/gdb-patches/2010-09/msg00287.html references section 6.7.3 of C99 which talks about arrays. But IMO C99 should talk even about structs/unions also containg its elements. Shouldn't be ISO C99 updated? Reproducer: const int a1[1]; __typeof__ (a1[0]) a2; const struct { int x; } b1; __typeof__ (b1.x) b2; gcc (GCC) 4.6.0 20100923 (experimental) -std=c99 -c -Wall -g GNU gdb (GDB) 7.2.50.20100923-cvs Actual: (gdb) ptype a1[0] type = int (gdb) ptype a2 type = const int (gdb) ptype b1.x type = int (gdb) ptype b2 type = const int <1><42>: Abbrev Number: 4 (DW_TAG_base_type) <45> DW_AT_name : int <1><49>: Abbrev Number: 5 (DW_TAG_array_type) <4a> DW_AT_type : <0x42> <2><52>: Abbrev Number: 6 (DW_TAG_subrange_type) <1><60>: Abbrev Number: 8 (DW_TAG_variable) <61> DW_AT_name : a1 <66> DW_AT_type : <0x6c> <1><6c>: Abbrev Number: 9 (DW_TAG_const_type) <6d> DW_AT_type : <0x49> <1><9c>: Abbrev Number: 10 (DW_TAG_variable) <9d> DW_AT_name : a2 <a2> DW_AT_type : <0xb1> <1><b1>: Abbrev Number: 9 (DW_TAG_const_type) <b2> DW_AT_type : <0x42> Expected: (gdb) ptype a1[0] type = const int (gdb) ptype a2 type = const int (gdb) ptype b1.x type = const int (gdb) ptype b2 type = const int <1><42>: Abbrev Number: 4 (DW_TAG_base_type) <45> DW_AT_name : int <1><49>: Abbrev Number: 5 (DW_TAG_array_type) <4a> DW_AT_type : <0xb1> <2><52>: Abbrev Number: 6 (DW_TAG_subrange_type) <1><60>: Abbrev Number: 8 (DW_TAG_variable) <61> DW_AT_name : a1 <66> DW_AT_type : <0x49> <1><9c>: Abbrev Number: 10 (DW_TAG_variable) <9d> DW_AT_name : a2 <a2> DW_AT_type : <0xb1> <1><b1>: Abbrev Number: 9 (DW_TAG_const_type) <b2> DW_AT_type : <0x42> But GDB probably should fix up the types anyway. Maybe related: PR debug/8354 - Incorrect DWARF-2/3 emitted for const + array -- Configure bugmail: http://gcc.gnu.org/bugzilla/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug.