<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 - Clang's debug info does not mark 'this' parameters 'const' but GCC and MSVC do"
href="https://bugs.llvm.org/show_bug.cgi?id=36526">36526</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Clang's debug info does not mark 'this' parameters 'const' but GCC and MSVC do
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>unspecified
</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>LLVM Codegen
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>rnk@google.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>$ cat t.cpp
struct Foo {
void f();
};
void Foo::f() {}
$ gcc -c t.cpp -g -o t.o && llvm-dwarfdump t.o
...
0x00000097: DW_TAG_pointer_type
DW_AT_byte_size (0x08)
DW_AT_type (cu + 0x006f "Foo")
0x0000009d: DW_TAG_const_type
DW_AT_type (cu + 0x0097 "Foo*")
0x000000a2: DW_TAG_subprogram
DW_AT_specification (cu + 0x007b "_ZN3Foo1fEv")
DW_AT_decl_line (4)
DW_AT_object_pointer (cu + 0x00c2)
DW_AT_low_pc (0x0000000000000000)
DW_AT_high_pc (0x000000000000000b)
DW_AT_frame_base (DW_OP_call_frame_cfa)
DW_AT_object_pointer (cu + 0x00c2)
DW_AT_GNU_all_call_sites (true)
0x000000c2: DW_TAG_formal_parameter
DW_AT_name ("this")
DW_AT_type (cu + 0x009d "const Foo*")
DW_AT_artificial (true)
DW_AT_location (DW_OP_fbreg +0)
$ clang -c t.cpp -g -o t.o && llvm-dwarfdump t.o
...
0x00000045: DW_TAG_pointer_type
DW_AT_type (cu + 0x002a "Foo")
0x0000004a: DW_TAG_subprogram
DW_AT_low_pc (0x0000000000000000)
DW_AT_high_pc (0x0000000000000007)
DW_AT_frame_base (DW_OP_reg7 RSP)
DW_AT_object_pointer (cu + 0x0062)
DW_AT_decl_line (4)
DW_AT_specification (cu + 0x0033 "?f@Foo@@QEAAXXZ")
0x00000062: DW_TAG_formal_parameter
DW_AT_location (DW_OP_fbreg +0)
DW_AT_name ("this")
DW_AT_type (cu + 0x006f "Foo*")
DW_AT_artificial (true)
Also, llvm-dwarfdump applies 'const' in the wrong place. It should appear to
the right of the pointer, as in 'Foo *const this', to indicate that Foo can be
modified, but 'this' cannot be made to point to another object.
Here is MSVC's opinion (note the 'IsConst: 1' below):
$ cl -c t.cpp -Z7 && llvm-readobj -codeview t.obj
...
Pointer (0x1001) {
TypeLeafKind: LF_POINTER (0x1002)
PointeeType: Foo (0x1000)
PointerAttributes: 0x1040C
PtrType: Near64 (0xC)
PtrMode: Pointer (0x0)
IsFlat: 0
IsConst: 1
IsVolatile: 0
IsUnaligned: 0
IsRestrict: 0
SizeOf: 8
}
ArgList (0x1002) {
TypeLeafKind: LF_ARGLIST (0x1201)
NumArgs: 0
Arguments [
]
}
MemberFunction (0x1003) {
TypeLeafKind: LF_MFUNCTION (0x1009)
ReturnType: void (0x3)
ClassType: Foo (0x1000)
ThisType: const Foo* (0x1001)
CallingConvention: NearC (0x0)
FunctionOptions [ (0x0)
]
NumParameters: 0
ArgListType: () (0x1002)
ThisAdjustment: 0
}
Given that both mainstream compilers disagree with us on this, we should
probably change our output.</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>