[Bug c++/68754] New: Explicitly defaulted constexpr assignment operator fails to compile
ldionne.2 at gmail dot com
gcc-bugzilla@gcc.gnu.org
Mon Dec 7 00:32:00 GMT 2015
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68754
Bug ID: 68754
Summary: Explicitly defaulted constexpr assignment operator
fails to compile
Product: gcc
Version: 5.3.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: ldionne.2 at gmail dot com
Target Milestone: ---
The following code fails to compile on GCC 5.3.0:
struct base { };
struct derived : base {
constexpr derived& operator=(derived const&) = default;
};
The error message is
[...]: error: explicitly defaulted function
'constexpr derived& derived::operator=(const derived&)' cannot
be declared as constexpr because the implicit declaration is
not constexpr:
constexpr derived& operator=(derived const&) = default;
^
[...]: note: defaulted constructor calls non-constexpr
'base& base::operator=(const base&)'
struct base { };
^
[...]: note: 'base& base::operator=(const base&)' is not usable as a
constexpr function because:
However, the default-generated assignment operator of `base` is constexpr.
Live example: http://melpon.org/wandbox/permlink/GUJHQDuVaWOkwObj
More information about the Gcc-bugs
mailing list