<html>
    <head>
      <base href="https://llvm.org/bugs/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - noexcept in destructor of class with anonymous union causes crash"
   href="https://llvm.org/bugs/show_bug.cgi?id=23584">23584</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>noexcept in destructor of class with anonymous union causes crash
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>3.5
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>-New Bugs
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>christian.r.shelton@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=14345" name="attach_14345" title="clang++ backtrace">attachment 14345</a> <a href="attachment.cgi?id=14345&action=edit" title="clang++ backtrace">[details]</a></span>
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);
}</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>