<html>
<head>
<base href="https://bugs.llvm.org/">
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - [Dwarf] Incorrect lexical scope information for constant arrays."
href="https://bugs.llvm.org/show_bug.cgi?id=32378">32378</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>[Dwarf] Incorrect lexical scope information for constant arrays.
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Windows NT
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>enhancement
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>-New Bugs
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>andrea.dibiagio@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>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]);
}
}
//////////////////////////////////////
<span class="quote">> clang -g -O0 -c test.cpp
> objdump --dwarf=info test.o</span >
<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:
<span class="quote">> gcc -g -O0 -c test.cpp
> objdump --dwarf=info test.o</span >
<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 <a class="bz_bug_link
bz_status_NEW "
title="NEW - Debug info not generated correctly for function static variables"
href="show_bug.cgi?id=19238">bug 19238</a> and <a class="bz_bug_link
bz_status_RESOLVED bz_closed"
title="RESOLVED DUPLICATE - Nested static vars in same DWARF scope"
href="show_bug.cgi?id=23164">bug 23164</a>.</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>