[Bug c++/71243] New: Implicitly defined assignment operator is not constexpr even though it should be
michele.caini at gmail dot com
gcc-bugzilla@gcc.gnu.org
Mon May 23 16:12:00 GMT 2016
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71243
Bug ID: 71243
Summary: Implicitly defined assignment operator is not
constexpr even though it should be
Product: gcc
Version: 5.3.1
Status: UNCONFIRMED
Severity: minor
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: michele.caini at gmail dot com
Target Milestone: ---
Explicitly defaulted constexpr assignment operator fails to compile.
See the minimal, failing example below:
struct S {
constexpr S& operator=(const S &) = default;
};
int main() { }
Tested on debian (Testing), g++ v5.3.1-19.
The same applies to g++ v5.3.0, while it works with g++ v6.1.0 (tested on
godbolt.org).
The error is:
2 : error: explicitly defaulted function 'constexpr S& S::operator=(const
S&)' cannot be declared as constexpr because the implicit declaration is not
constexpr:
constexpr S& operator=(const S &) = default;
^
Compilation failed
According to 12.8p26, it should compile for the one implicitly defined ought to
be constexpr too.
More information about the Gcc-bugs
mailing list