Quuxplusone / LLVMBugzillaTest

0 stars 0 forks source link

dtors run twice #6305

Closed Quuxplusone closed 14 years ago

Quuxplusone commented 14 years ago
Bugzilla Link PR5826
Status RESOLVED FIXED
Importance P normal
Reported by Mike Stump (mikestump@comcast.net)
Reported on 2009-12-17 20:58:47 -0800
Last modified on 2010-02-22 12:44:51 -0800
Version trunk
Hardware PC All
CC andersca@icloud.com, dgregor@apple.com, llvm-bugs@lists.llvm.org
Fixed by commit(s)
Attachments
Blocks
Blocked by
See also
extern "C" void abort ();

int ctor = 0;
int dtor = 0;

template <class T> struct A {
    A() {ctor++;}
    A(int) {ctor++;}
    A(const A&) {ctor++;}
    ~A() {dtor++;}
    operator int() {return 0;}
};

void f() {
  A<short> a4 = 97;
}

int
main() {
  f();

  if (!ctor || ctor != dtor)
    return 1;

  return 0;
}

runs the dtor twice; once from EmitLocalBlockVarDecl, and once from
EmitCXXExprWithTemporaries.
Quuxplusone commented 14 years ago

We're binding constructions that aren't temporaries; I'll take this as part of InitializerSequence's path to world domination.

Quuxplusone commented 14 years ago
Fixed here:

  http://lists.cs.uiuc.edu/pipermail/cfe-commits/Week-of-Mon-20091214/025626.html