diff options
author | John McCall <rjmccall@apple.com> | 2011-01-27 02:46:02 +0000 |
---|---|---|
committer | John McCall <rjmccall@apple.com> | 2011-01-27 02:46:02 +0000 |
commit | fd708265e3b1dcfaae6a6832186aabb0de0c0aef (patch) | |
tree | 5e9ed4935ec661694f21498637d1aa7ee8385ea0 | |
parent | f2eca2cf302c50b79891f24b3861d64ea9263831 (diff) |
Notes on dynamic array cookies in MSVC.
My thanks to chapuni for his help in investigating this.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@124351 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/CodeGen/MicrosoftCXXABI.cpp | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/lib/CodeGen/MicrosoftCXXABI.cpp b/lib/CodeGen/MicrosoftCXXABI.cpp index ea2e55fcb2..3a63eba397 100644 --- a/lib/CodeGen/MicrosoftCXXABI.cpp +++ b/lib/CodeGen/MicrosoftCXXABI.cpp @@ -55,6 +55,29 @@ public: EmitThisParam(CGF); // TODO: 'for base' flag } + + // ==== Notes on array cookies ========= + // + // MSVC seems to only use cookies when the class has a destructor; a + // two-argument usual array deallocation function isn't sufficient. + // + // For example, this code prints "100" and "1": + // struct A { + // char x; + // void *operator new[](size_t sz) { + // printf("%u\n", sz); + // return malloc(sz); + // } + // void operator delete[](void *p, size_t sz) { + // printf("%u\n", sz); + // free(p); + // } + // }; + // int main() { + // A *p = new A[100]; + // delete[] p; + // } + // Whereas it prints "104" and "104" if you give A a destructor. }; } |