[llvm-bugs] [Bug 32378] New: [Dwarf] Incorrect lexical scope information for constant arrays.

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Mar 22 10:13:29 PDT 2017


https://bugs.llvm.org/show_bug.cgi?id=32378

            Bug ID: 32378
           Summary: [Dwarf] Incorrect lexical scope information for
                    constant arrays.
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: andrea.dibiagio at gmail.com
                CC: llvm-bugs at lists.llvm.org

Reproducible:

///////////// test.cpp ///////////////
void bar(int);
void foo() {
  {
    const int someArray[] = {1, 2};
    bar(someArray[0]);
  }

  {
    const int someArray[] = {3, 4, 5};
    bar(someArray[0]);
  }
}
//////////////////////////////////////

> clang -g -O0 -c test.cpp
> objdump --dwarf=info test.o


 <1><2a>: Abbrev Number: 2 (DW_TAG_subprogram)
    <39>   DW_AT_linkage_name: (indirect string, offset: 0x57): _Z3foov
 <2><43>: Abbrev Number: 3 (DW_TAG_variable)
    <44>   DW_AT_name        : (indirect string, offset: 0x40): someArray
    <48>   DW_AT_type        : <0x6e>
    <4c>   DW_AT_decl_file   : 1
    <4d>   DW_AT_decl_line   : 4
    <4e>   DW_AT_location    : 9 byte block: 3 0 0 0 0 0 0 0 0  (DW_OP_addr: 0)
 <2><58>: Abbrev Number: 3 (DW_TAG_variable)
    <59>   DW_AT_name        : (indirect string, offset: 0x40): someArray
    <5d>   DW_AT_type        : <0x8d>
    <61>   DW_AT_decl_file   : 1
    <62>   DW_AT_decl_line   : 9
    <63>   DW_AT_location    : 9 byte block: 3 8 0 0 0 0 0 0 0  (DW_OP_addr: 8)


Both 'someArray' arrays are associated to the subprogram lexical scope.
That is wrong because each one should be associated to a distinct lexical scope
nested within the subprogram scope.

GCC (I am using version 5.4.0 20160609) instead emits those two arrays in
distinct lexical blocks:

> gcc -g -O0 -c test.cpp
> objdump --dwarf=info test.o


 <1><2d>: Abbrev Number: 2 (DW_TAG_subprogram)
    <34>   DW_AT_linkage_name: (indirect string, offset: 0x0): _Z3foov
 <2><4e>: Abbrev Number: 3 (DW_TAG_lexical_block)
    <4f>   DW_AT_low_pc      : 0x4
    <57>   DW_AT_high_pc     : 0xd
    <5f>   DW_AT_sibling     : <0x79>
 <3><63>: Abbrev Number: 4 (DW_TAG_variable)
    <64>   DW_AT_name        : (indirect string, offset: 0x1a): someArray
    <68>   DW_AT_decl_file   : 1
    <69>   DW_AT_decl_line   : 4
    <6a>   DW_AT_type        : <0xc4>
    <6e>   DW_AT_location    : 9 byte block: 3 0 0 0 0 0 0 0 0  (DW_OP_addr: 0)
 <3><78>: Abbrev Number: 0
 <2><79>: Abbrev Number: 5 (DW_TAG_lexical_block)
    <7a>   DW_AT_low_pc      : 0x11
    <82>   DW_AT_high_pc     : 0xd
 <3><8a>: Abbrev Number: 4 (DW_TAG_variable)
    <8b>   DW_AT_name        : (indirect string, offset: 0x1a): someArray
    <8f>   DW_AT_decl_file   : 1
    <90>   DW_AT_decl_line   : 9
    <91>   DW_AT_type        : <0xd9>
    <95>   DW_AT_location    : 9 byte block: 3 8 0 0 0 0 0 0 0  (DW_OP_addr: 8)

This is very likely to be another instance of bug 19238 and bug 23164.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20170322/b346437d/attachment.html>


More information about the llvm-bugs mailing list