https://bugs.llvm.org/show_bug.cgi?id=38983
Bug ID: 38983
Summary: Spurious interaction between noexcept specs. for
move/copy assignment
Product: clang
Version: unspecified
Hardware: PC
OS: MacOS X
Status: NEW
Severity: normal
Priority: P
Component: C++
Assignee: unassignedclangb...@nondot.org
Reporter: oliver.ros...@googlemail.com
CC: dgre...@apple.com, llvm-bugs@lists.llvm.org
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.
--
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs