https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94847
Bug ID: 94847 Summary: -fdebug-types-section drops const in type Product: gcc Version: 10.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: debug Assignee: unassigned at gcc dot gnu.org Reporter: vries at gcc dot gnu.org Target Milestone: --- Consider test-case gdb/testsuite/gdb.base/constvars.c ( https://sourceware.org/git/?p=binutils-gdb.git;a=blob_plain;f=gdb/testsuite/gdb.base/constvars.c;hb=HEAD ). Compiled with debug info: ... $ gcc -g constvars.c ... we have the expected: ... $ gdb -batch a.out -ex start -ex "ptype victor" Temporary breakpoint 1 at 0x4004f4: file constvars.c, line 24. Temporary breakpoint 1, main () at constvars.c:24 24 char lave = 'B'; type = const volatile char ... However, compiled with -fdebug-types-section in addition: ... $ gcc -g -fdebug-types-section constvars.c ... we have instead: ... $ gdb -batch a.out -ex start -ex "ptype victor" Temporary breakpoint 1 at 0x4004f4: file constvars.c, line 24. Temporary breakpoint 1, main () at constvars.c:24 24 char lave = 'B'; type = volatile char ... So, the 'const' got dropped. Looking at the debug info, in the first case we have: ... <2><64b>: Abbrev Number: 3 (DW_TAG_variable) <64c> DW_AT_name : victor <652> DW_AT_type : <0x826> <1><826>: Abbrev Number: 8 (DW_TAG_const_type) <827> DW_AT_type : <0x821> <1><821>: Abbrev Number: 9 (DW_TAG_volatile_type) <822> DW_AT_type : <0x815> <1><815>: Abbrev Number: 10 (DW_TAG_base_type) <816> DW_AT_byte_size : 1 <817> DW_AT_encoding : 6 (signed char) <818> DW_AT_name : char ... but in the second case we have: ... <2><64b>: Abbrev Number: 3 (DW_TAG_variable) <64c> DW_AT_name : victor <652> DW_AT_type : <0x821> <1><821>: Abbrev Number: 9 (DW_TAG_volatile_type) <822> DW_AT_type : <0x815> <1><815>: Abbrev Number: 10 (DW_TAG_base_type) <816> DW_AT_byte_size : 1 <817> DW_AT_encoding : 6 (signed char) <818> DW_AT_name : char ...