<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 --- - [-cxx-abi microsoft] Support vtordisp thunks"
href="http://llvm.org/bugs/show_bug.cgi?id=17738">17738</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>[-cxx-abi microsoft] Support vtordisp thunks
</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>C++
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>timurrrr@google.com
</td>
</tr>
<tr>
<th>CC</th>
<td>dgregor@apple.com, llvmbugs@cs.uiuc.edu
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>This ABI tries hard to avoid "virtual this adjustment". It's not always
possible though.
Consider the following example:
-------------
struct A {
virtual void f(); // Expects "(A*)this" in ECX
};
struct B : virtual A {
virtual void f(); // Expects "(char*)(B*)this + 12" in ECX
virtual ~B(); // Might call f()
};
----
B::f assumes that the class layout is |BA| and uses static "-12" this
adjustment in the prologue.
However, if a class overrides a virtual function of its base and has a
non-trivial ctor/dtor that call this virtual function (or may escape "this" to
some code that might call it), a virtual adjustment might be needed, in case
the current class layout and the most derived class layout are different.
For example, in this class:
-------------
struct C : virtual B {
virtual void f();
};
-------------
the layout is |CAB|.
If f() is called during B ctor or dtor, the thunk that's stored in B's the
vftable should apply a "+4+12" this adjustment so B::f() gets the right value
of this in the prologue. The extra adjustment is not needed if B is the most
derived class, i.e. the exact adjustment should be determined dynamically. The
value of the dynamic adjustment is stored in the hidden vtordisp associated
with the A vbase, hence the thunk is called a "vtordisp thunk".</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>