llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
28.77k stars 11.9k forks source link

clang tries to match exception specification for an explictly defaulted but implicitly deleted function #19036

Open llvmbot opened 10 years ago

llvmbot commented 10 years ago
Bugzilla Link 18662
Version trunk
OS All
Reporter LLVM Bugzilla Contributor
CC @DougGregor,@zygoloid

Extended Description

The following example seems to fail to compile because clang tries to match the exception specification for the explicitly defaulted but implicitly deleted move assignment operator of Wrapper with a bogus exception specification it calculated for the implicitly deleted function.

class Value {
public:
  Value();
  Value& operator=(const Value& other);
  Value& operator=(Value&& other) noexcept;
};

template <typename T>
struct Wrapper {
   T value;

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

Wrapper<const Value> value;
lang++ -std=c++11 test.cpp
test.cpp:13:13: error: exception specification of explicitly defaulted move assignment operator does not match the calculated one
   Wrapper& operator=(Wrapper&&) noexcept = default;
            ^
test.cpp:16:22: note: in instantiation of template class 'Wrapper<const Value>' requested here
Wrapper<const Value> value;
                     ^
1 error generated.
ec04fc15-fa35-46f2-80e1-5d271f2ef708 commented 10 years ago

This should be fixed when we implement DR1778.