https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91507

            Bug ID: 91507
           Summary: wrong debug for completed array with previous
                    incomplete declaration
           Product: gcc
           Version: 7.4.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: debug
          Assignee: unassigned at gcc dot gnu.org
          Reporter: rguenth at gcc dot gnu.org
  Target Milestone: ---

extern char *zzz[];
char *zzz[ ] = {
    "abc",
    "cde"
};

according to the C standard the array type of zzz is completed at the end
of the initializer list but we emit the following dwarf where the definition
inherits the type specification of the declaration:

 <1><1d>: Abbrev Number: 2 (DW_TAG_array_type)
    <1e>   DW_AT_type        : <0x28>
    <22>   DW_AT_sibling     : <0x28>
 <2><26>: Abbrev Number: 3 (DW_TAG_subrange_type)
 <2><27>: Abbrev Number: 0
...
 <1><35>: Abbrev Number: 6 (DW_TAG_variable)
    <36>   DW_AT_name        : zzz
    <3a>   DW_AT_decl_file   : 1
    <3b>   DW_AT_decl_line   : 1
    <3c>   DW_AT_decl_column : 14
    <3d>   DW_AT_type        : <0x1d>
    <41>   DW_AT_external    : 1
    <41>   DW_AT_declaration : 1
...
 <1><48>: Abbrev Number: 7 (DW_TAG_variable)
    <49>   DW_AT_specification: <0x35>
    <4d>   DW_AT_decl_line   : 2
    <4e>   DW_AT_decl_column : 7
    <4f>   DW_AT_location    : 9 byte block: 3 0 0 0 0 0 0 0 0  (DW_OP_addr: 0)

technically this is a regression from before early-debug where we omitted
debug info for the declaration.  Correct debug info is emitted if the
declaration is omitted.

Reply via email to