[Bug c++/88165] New: error: default member initializer for 'A::B::m' required before the end of its enclosing class
leanid.chaika at gmail dot com
gcc-bugzilla@gcc.gnu.org
Fri Nov 23 11:56:00 GMT 2018
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88165
Bug ID: 88165
Summary: error: default member initializer for 'A::B::m'
required before the end of its enclosing class
Product: gcc
Version: 8.2.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: leanid.chaika at gmail dot com
Target Milestone: ---
The following compiles with MSVC2017 and not with gcc8.2. This bug was reported
first on stackoverflow
(https://stackoverflow.com/questions/53408962/try-to-understand-compiler-error-message-default-member-initializer-required-be)
minimum code example:
-prog.cc-------------------------
#include <limits>
class A
{
public:
class B
{
public:
explicit B() = default;
~B() = default;
private:
double m = std::numeric_limits<double>::max();
};
void f(double d, const B &b = B{}) {}
};
int main()
{
A a{};
a.f(0.);
}
--------------------------------
compile command:
g++ prog.cc -std=c++17
--------------------------------
error message:
prog.cc:15:36: error: default member initializer for 'A::B::m' required before
the end of its enclosing class
void f(double d, const B &b = B{}) {}
^
prog.cc:12:22: note: defined here
double m = std::numeric_limits<double>::max();
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
More information about the Gcc-bugs
mailing list