<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </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 - Spurious interaction between noexcept specs. for move/copy assignment"
   href="https://bugs.llvm.org/show_bug.cgi?id=38983">38983</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Spurious interaction between noexcept specs. for move/copy assignment
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>unspecified
          </td>
        </tr>

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

        <tr>
          <th>OS</th>
          <td>MacOS X
          </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>C++
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>oliver.rosten@googlemail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>dgregor@apple.com, llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>The following (contrived) code appears to indicate a spurious dependency
between the exception specifications for the move/copy assignment operators.

template<class T>
class wrapper
{
  T& m_Ref; 
// Reported problem disappears if reference_wrapper is used instead
public:
  wrapper(T& ref) : m_Ref{ref} {}

  wrapper(const wrapper&)            = default;
  wrapper(wrapper&&)                 noexcept = default;
  wrapper& operator=(const wrapper&) noexcept(false){} 
  // 'false' required to reveal bug; 
  //removing false fixes compilation
  wrapper& operator=(wrapper&&)      noexcept = default;

};

template<class T, class W>
class thing
{
private:
  W m_Member{};
public:
  thing(T& ref) : m_Member{ref} {}

  thing(const thing&) = default;
  thing(thing&&)      = default;

  thing& operator=(const thing&)     = default;
  thing& operator=(thing&&) noexcept = default;
};

int x{5};
wrapper<int> w{x}; // fine
thing<int, wrapper<int>> foo{x}; 

Compiler error message:
  exception specification of
  explicitly defaulted move assignment operator does not match the
  calculated one
    thing& operator=(thing&&) noexcept = default;

The last line of code fails to compile due to the exception spec of the *move*
assignment operator not matching the calculated one.

Compilation may be fixed by changing the exception spec. of the *copy*
assignment operator.</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>