<html>
<head>
<base href="http://llvm.org/bugs/" />
</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 --- - Const integer variables are duplicated in the root scope"
href="http://llvm.org/bugs/show_bug.cgi?id=19298">19298</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Const integer variables are duplicated in the root scope
</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>normal
</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>katya_romanova@playstation.sony.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvmbugs@cs.uiuc.edu
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>A 'const int' variable declared in a function gets two separate entries in the
DWARF debug info generated by LLVM; there should be only one entry. The
extraneous copy is created in the root scope of the debug information. This
problem only affects integer-type constants.
The simple example attached shows a const variable 'd' declared in the main
function. Examining the DWARF debug info shows that it appears twice in the
debug info; once inside the main function, and once at the root level. The
example is compiled without optimizations (-O0).
========================
int main()
{
const int d = 4;
const float e = 4;
const char* f = "Woopy";
return d;
}
========================
<0><b>: Abbrev Number: 1 (DW_TAG_compile_unit)
<c> DW_AT_producer : (indirect string, offset: 0x0): clang version
3.5.0 (trunk 203177)
<10> DW_AT_language : 4 (C++)
<12> DW_AT_name : (indirect string, offset: 0x23): main.cpp
<16> DW_AT_stmt_list : 0x0
<1a> DW_AT_comp_dir : (indirect string, offset: 0x2c):
/home/kromanova/
<1e> DW_AT_low_pc : 0x0
<1><26>: Abbrev Number: 2 (DW_TAG_variable)
<27> DW_AT_name : (indirect string, offset: 0x62): d
<2b> DW_AT_type : <0x32>
<2f> DW_AT_decl_file : 1
<30> DW_AT_decl_line : 3
<31> DW_AT_const_value : 4
.............
<1><3e>: Abbrev Number: 5 (DW_TAG_subprogram)
<3f> DW_AT_name : (indirect string, offset: 0x68): main
<43> DW_AT_decl_file : 1
<44> DW_AT_decl_line : 1
<45> DW_AT_type : <0x37>
<49> DW_AT_external : 1
<49> DW_AT_accessibility: 1 (public)
<4a> DW_AT_low_pc : 0x0
<52> DW_AT_high_pc : 0x39
<5a> DW_AT_frame_base : 1 byte block: 56 (DW_OP_reg6 (rbp))
<2><5c>: Abbrev Number: 6 (DW_TAG_variable)
<5d> DW_AT_name : (indirect string, offset: 0x62): d
<61> DW_AT_decl_file : 1
<62> DW_AT_decl_line : 3
<63> DW_AT_type : <0x32>
<67> DW_AT_location : 2 byte block: 91 78 (DW_OP_fbreg: -8)</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>