title: Constexpr destructor of a class with union field containing not-trivial type
body: <p>In the following program not-literal struct <code>A</code> is used inside of <code>union</code> field of another class defining <code>constexpr</code> destructor:</p>
  <pre><code>struct A { 
      A() {}
      ~A() {}
  };
  
  struct S {
    union {
      int i;
      A a;
    };
    enum { ti, ta } type;
  
    constexpr S() : i(1), type(ti) {}
    constexpr ~S() {
        if ( type == ta ) a.~A();
    }
  };
  
  static_assert( S{}.i == 1 );
  </code></pre>
  <p>GCC permits this code, but Clang emits the error:</p>
  <pre><code>error: destructor cannot be declared constexpr because data member '' does not have a constexpr destructor
  </code></pre>
  <p>MSVC also rejects it:</p>
  <pre><code>error C3615: constexpr function 'S::~S' cannot result in a constant expression
  note: failure was caused by call of undefined function or one not declared 'constexpr'
  note: see usage of 'A::~A'
  </code></pre>
  <p>Demo: <a href="https://gcc.godbolt.org/z/qKW45fdE6" rel="nofollow noreferrer">https://gcc.godbolt.org/z/qKW45fdE6</a></p>
  <p>Which compiler is right here?</p>