[LLVMbugs] [Bug 23584] New: noexcept in destructor of class with anonymous union causes crash

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Tue May 19 16:02:13 PDT 2015


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

            Bug ID: 23584
           Summary: noexcept in destructor of class with anonymous union
                    causes crash
           Product: clang
           Version: 3.5
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: christian.r.shelton at gmail.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

Created attachment 14345
  --> https://llvm.org/bugs/attachment.cgi?id=14345&action=edit
clang++ backtrace

This is as simple as I've been able to get the example.  The code has a bug (it
does not destruct either union member).  The original had this logic, but it
wasn't necessary to trigger the clang++ abort, so I removed it:


template<typename T>
struct wrap {
     T x;
     constexpr wrap(const T &xx) : x(xx) {}
};

template<typename R1, typename R2>
struct commonunion_node {
     typedef wrap<R1> type1;
     typedef wrap<R2> type2;

     union {
          type1 t1;
          type2 t2;
     };

     constexpr commonunion_node(R1 &tt1) : t1(tt1) {}
     constexpr commonunion_node(R2 &tt2) : t2(tt2) {}

     ~commonunion_node() noexcept {} // remove "noexcept" to "fix" crash
};

struct A {
     ~A() {}
};
struct B {
     ~B() {}
};


int main(int argv, char **argc) {
     A a;
     commonunion_node<A,B> cu(a);
}

-- 
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/20150519/25295fcf/attachment.html>


More information about the llvm-bugs mailing list