<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 --- - MS ABI: Incorrect this adjustment in base dtor when dtor is in non-primary vftable"
href="http://llvm.org/bugs/show_bug.cgi?id=18845">18845</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>MS ABI: Incorrect this adjustment in base dtor when dtor is in non-primary vftable
</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>normal
</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>rnk@google.com
</td>
</tr>
<tr>
<th>CC</th>
<td>dgregor@apple.com, llvmbugs@cs.uiuc.edu
</td>
</tr>
<tr>
<th>Blocks</th>
<td>12477
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>When the primary base lacks a virtual destructor and a non-primary base has
one, we add this adjustments in destructor variants that don't require them.
This test case exhibits the problem:
$ cat t.cpp
int count;
struct A {
virtual void f() {}
};
struct B {
virtual ~B() {
count += b;
}
int b;
};
struct C : A, B {
virtual ~C() {
count += c;
}
int c;
};
int main() {
C *p = new C();
p->b = 2;
p->c = 3;
delete p;
return count;
}
$ cl t.cpp && ./t.exe ; echo $?
5
$ clang-cl t.cpp && ./t.exe ; echo $?
127 (crash?)
The problem is that we emit this adjustments in *all* destructor variants,
rather than just the variant installed in the vftable:
$ clang-cl -GR- t.cpp -c && dumpbin /disasm t.obj | grep -B8 FFFFC
??_EC@@W3AEPAXI@Z ([thunk]:public: virtual void * __thiscall C::`vector
deleting destructor'`adjustor{4}' (unsigned int)):
00000000: 55 push ebp
00000001: 89 E5 mov ebp,esp
00000003: 83 EC 0C sub esp,0Ch
00000006: 8B 45 08 mov eax,dword ptr [ebp+8]
00000009: 89 45 FC mov dword ptr [ebp-4],eax
0000000C: 89 4D F8 mov dword ptr [ebp-8],ecx
0000000F: 8B 45 FC mov eax,dword ptr [ebp-4]
00000012: 83 C1 FC add ecx,0FFFFFFFCh
--
??_GC@@UAEPAXI@Z (public: virtual void * __thiscall C::`scalar deleting
destructor'(unsigned int)):
00000000: 55 push ebp
00000001: 89 E5 mov ebp,esp
00000003: 83 EC 14 sub esp,14h
00000006: 8B 45 08 mov eax,dword ptr [ebp+8]
00000009: 81 C1 FC FF FF FF add ecx,0FFFFFFFCh
--
??1C@@UAE@XZ (public: virtual __thiscall C::~C(void)):
00000000: 55 push ebp
00000001: 89 E5 mov ebp,esp
00000003: 50 push eax
00000004: 89 C8 mov eax,ecx
00000006: 83 C0 FC add eax,0FFFFFFFCh
Only the vector deleting destructor should do any adjustment.</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>