[LLVMbugs] [Bug 11590] New: template class destructor not called

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Thu Dec 15 12:34:19 PST 2011


http://llvm.org/bugs/show_bug.cgi?id=11590

             Bug #: 11590
           Summary: template class destructor not called
           Product: clang
           Version: 3.0
          Platform: Macintosh
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: benoit at bittrap.com
                CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
    Classification: Unclassified


A destructor isn't called in the test case below (works with gcc 4.2.1 and
MSVC2010).

-----
#include <iostream>

using namespace std;

template<typename T> class Handle {
public:

    Handle() { cout << "Handle::Handle()" << endl; }

    Handle(const Handle& r) { cout << "Handle::Handle(Handle&)" << endl; }

    ~Handle() { cout << "Handle::~Handle()" << endl; }
};

class P {
public:
    Handle<int> h;

    Handle<int> getHandle() {
        return h;
    }

    template<class T> void 
    f(Handle<T>& h) {
        h = getHandle();
    }
};

int
main(int, char**) {
    P p;
    Handle<int> h;
    p.f(h);
}
----

MacBookPro:~/Devel/git/game$ clang++ -v
Apple clang version 3.0 (tags/Apple/clang-211.10.1) (based on LLVM 3.0svn)
Target: x86_64-apple-darwin11.2.0
Thread model: posix
MacBookPro:~/Devel/git/game$ ./a.out 
Handle::Handle()
Handle::Handle()
Handle::Handle(Handle&)
Handle::~Handle()
Handle::~Handle()

-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list