[LLVMbugs] [Bug 18845] New: MS ABI: Incorrect this adjustment in base dtor when dtor is in non-primary vftable
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Fri Feb 14 12:18:38 PST 2014
http://llvm.org/bugs/show_bug.cgi?id=18845
Bug ID: 18845
Summary: MS ABI: Incorrect this adjustment in base dtor when
dtor is in non-primary vftable
Product: clang
Version: unspecified
Hardware: PC
OS: Windows NT
Status: NEW
Severity: normal
Priority: P
Component: C++
Assignee: unassignedclangbugs at nondot.org
Reporter: rnk at google.com
CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
Blocks: 12477
Classification: Unclassified
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 at 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 at 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 at 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.
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20140214/5af72d59/attachment.html>
More information about the llvm-bugs
mailing list