http://llvm.org/bugs/show_bug.cgi?id=19398
Bug ID: 19398
Summary: Implement vector deleting destructors
Product: clang
Version: unspecified
Hardware: PC
OS: Windows NT
Status: NEW
Severity: normal
Priority: P
Component: LLVM Codegen
Assignee: [email protected]
Reporter: [email protected]
CC: [email protected], [email protected],
[email protected]
Blocks: 12477
Classification: Unclassified
MSVC supports an extension that allows users to delete an array of polymorphic
objects where the dynamic type doesn't match the static type of the array.
Here's an example of MSVC doing this where we can't:
$ cat t.cpp
extern "C" int printf(const char *, ...);
struct A {
A() : a(42) {}
virtual ~A() { printf("a: %d\n", a); }
int a;
};
struct B : A {
B() : b(13) {}
~B() { printf("b: %d\n", b); }
int b;
};
void foo(A *a) { delete[] a; }
int main() {
B *b = new B[2];
foo(b);
}
$ cl -nologo t.cpp && ./t.exe
t.cpp
b: 13
a: 42
b: 13
a: 42
$ clang-cl t.cpp && ./t.exe
a: 16699704
a: 42
They use "vector deleting destructors" to do this special array deletion, and
those are what go in the vftable. We currently put the scalar deleting dtor
there instead.
--
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs