This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/71243] New: Implicitly defined assignment operator is not constexpr even though it should be
- From: "michele.caini at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Mon, 23 May 2016 16:12:30 +0000
- Subject: [Bug c++/71243] New: Implicitly defined assignment operator is not constexpr even though it should be
- Auto-submitted: auto-generated
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.