-
Notifications
You must be signed in to change notification settings - Fork 15.2k
Closed
Labels
ABIApplication Binary InterfaceApplication Binary InterfacebugzillaIssues migrated from bugzillaIssues migrated from bugzillac++clang:codegenIR generation bugs: mangling, exceptions, etc.IR generation bugs: mangling, exceptions, etc.clang:frontendLanguage frontend issues, e.g. anything involving "Sema"Language frontend issues, e.g. anything involving "Sema"extension:microsoft
Description
| Bugzilla Link | 19398 |
| Version | unspecified |
| OS | Windows NT |
| Blocks | #12849 |
| CC | @majnemer,@timurrrr |
Extended Description
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.cppextern "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: 42They 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.
Metadata
Metadata
Assignees
Labels
ABIApplication Binary InterfaceApplication Binary InterfacebugzillaIssues migrated from bugzillaIssues migrated from bugzillac++clang:codegenIR generation bugs: mangling, exceptions, etc.IR generation bugs: mangling, exceptions, etc.clang:frontendLanguage frontend issues, e.g. anything involving "Sema"Language frontend issues, e.g. anything involving "Sema"extension:microsoft