[LLVMbugs] [Bug 19398] New: Implement vector deleting destructors

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Thu Apr 10 18:11:25 PDT 2014


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: unassignedclangbugs at nondot.org
          Reporter: rnk at google.com
                CC: david.majnemer at gmail.com, llvmbugs at cs.uiuc.edu,
                    timurrrr at google.com
            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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20140411/c4bf5da0/attachment.html>


More information about the llvm-bugs mailing list