Open mclow opened 6 years ago
Still persists in Clang 13 with constexpr constructors.
This issue doesn't appear in GCC 11.2 and Clang 13 with -std=c++17, but it only appears when the flag -std=c++20
is given.
Below is the sample code:
struct Foo {
constexpr Foo(const Foo&) noexcept = default;
constexpr Foo(Foo&&) noexcept = default;
constexpr auto operator=(const Foo&) noexcept -> Foo& = default;
constexpr auto operator=(Foo&&) noexcept -> Foo& = default;
};
with the following errors:
<source>:5:3: error: defaulted definition of copy assignment operator is not constexpr
constexpr auto operator=(const Foo&) noexcept -> Foo& = default;
^
<source>:6:3: error: defaulted definition of move assignment operator is not constexpr
constexpr auto operator=(Foo&&) noexcept -> Foo& = default;
^
2 errors generated.
Compiler returned: 1
Live demo: https://godbolt.org/z/6Mz6K3PMf
As shown above, the warning states that both assignment operators are not constexpr even though they are already declared constexpr, which is contradictory.
duplicate of llvm/llvm-project#26063 ?
Extended Description
Consider this code:
When compiled with a recent clang [clang version 7.0.0 (trunk 336548)], (
-std=c++2a
) it gives an error:then it compiles w/o error.
However, I believe that it should compile w/o error in both cases.