<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 - Incorrect type for 'this' in debuginfo for non-virtual thunks"
href="https://bugs.llvm.org/show_bug.cgi?id=42627">42627</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Incorrect type for 'this' in debuginfo for non-virtual thunks
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>8.0
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Linux
</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>C++
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>roc@ocallahan.org
</td>
</tr>
<tr>
<th>CC</th>
<td>blitzrakete@gmail.com, dgregor@apple.com, erik.pilkington@gmail.com, llvm-bugs@lists.llvm.org, richard-llvm@metafoo.co.uk
</td>
</tr></table>
<p>
<div>
<pre>Created <span class=""><a href="attachment.cgi?id=22245" name="attach_22245" title="testcase">attachment 22245</a> <a href="attachment.cgi?id=22245&action=edit" title="testcase">[details]</a></span>
testcase
Compile attached testcase with
clang++ -g -o /tmp/test /tmp/test.cc
Then dwarfdump -i /tmp/test shows, in part:
< 1><0x000000cc> DW_TAG_class_type
DW_AT_containing_type <0x0000010e>
DW_AT_calling_convention DW_CC_pass_by_reference
DW_AT_name Derived
DW_AT_byte_size 0x00000018
DW_AT_decl_file 0x00000001
/home/roc/tmp/test.cc
DW_AT_decl_line 0x00000010
...
< 1><0x0000021c> DW_TAG_subprogram
DW_AT_low_pc 0x004012f0
DW_AT_high_pc <offset-from-lowpc>22
DW_AT_frame_base len 0x0001: 56: DW_OP_reg6
DW_AT_object_pointer <0x00000235>
DW_AT_linkage_name _ZThn8_N7Derived4funcEv
DW_AT_decl_file 0x00000001
/home/roc/tmp/test.cc
DW_AT_decl_line 0x00000012
DW_AT_artificial yes(1)
DW_AT_external yes(1)
< 2><0x00000235> DW_TAG_formal_parameter
DW_AT_location len 0x0002: 9178:
DW_OP_fbreg -8
DW_AT_name this
DW_AT_type <0x00000242>
DW_AT_artificial yes(1)
< 1><0x00000242> DW_TAG_pointer_type
DW_AT_type <0x000000cc>
In particular 'this' is given type 'Derived', but in fact, in the thunk, it is
never a pointer to `Derived`, only `Base`. Here's the disasssembled thunk:
Dump of assembler code for function _ZThn8_N7Derived4funcEv:
=> 0x00000000004012f0 <+0>: push %rbp
0x00000000004012f1 <+1>: mov %rsp,%rbp
0x00000000004012f4 <+4>: mov %rdi,-0x8(%rbp)
0x00000000004012f8 <+8>: mov -0x8(%rbp),%rdi
0x00000000004012fc <+12>: add $0xfffffffffffffff8,%rdi
0x0000000000401300 <+16>: pop %rbp
0x0000000000401301 <+17>: jmpq 0x4012c0 <Derived::func()>
`DW_OP_fbreg -8` is always the incoming parameter value, which points to
`Base`.</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>