[llvm-bugs] [Bug 30689] New: Missing destructor on inner structure when initialized using initializer list

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Oct 13 09:40:45 PDT 2016


https://llvm.org/bugs/show_bug.cgi?id=30689

            Bug ID: 30689
           Summary: Missing destructor on inner structure when initialized
                    using initializer list
           Product: clang
           Version: trunk
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++11
          Assignee: unassignedclangbugs at nondot.org
          Reporter: valery.pykhtin at gmail.com
                CC: dgregor at apple.com, llvm-bugs at lists.llvm.org
    Classification: Unclassified

The following testcase fails to compile with ToT clang:


template <typename T>
class UP {
public:
  T *p;
  UP() : p(0) {}
  UP(T* _p) : p(_p) {}
  ~UP() { delete p; }
};

typedef struct Inner
{
  UP<double> a;
} Inner;

typedef struct Outer
{
  Inner      inner;
  UP<double> b;
} Outer;

int main(void) {
//  UP<Outer> p(new Outer()); // <-- This works!
  UP<Outer> p(new Outer{}); // <-- This fails!
  return 0;
}



> clang++ -std=c++11 test.cpp
/tmp/test-a1fad6.o: In function `main':
test.cpp:(.text+0x94): undefined reference to `Inner::~Inner()'
/tmp/test-a1fad6.o: In function `Outer::~Outer()':
test.cpp:(.text._ZN5OuterD2Ev[_ZN5OuterD2Ev]+0x28): undefined reference to
`Inner::~Inner()'
clang-4.0: error: linker command failed with exit code 1 (use -v to see
invocation)

-- 
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/20161013/48c7f0d4/attachment.html>


More information about the llvm-bugs mailing list