[Bug c++/92590] New: Cannot expose protected default constructor with "using" keyword in gcc 10
proski at gnu dot org
gcc-bugzilla@gcc.gnu.org
Wed Nov 20 01:13:00 GMT 2019
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92590
Bug ID: 92590
Summary: Cannot expose protected default constructor with
"using" keyword in gcc 10
Product: gcc
Version: 10.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: proski at gnu dot org
Target Milestone: ---
This code fails to compile with the current gcc (commit
d9be9f34fbb018c448dc5a02aaa95d6a6932135c)
class Base {
protected:
Base();
};
class Derived : public Base {
public:
using Base::Base;
};
Derived d;
test.ii:11:9: error: ‘Base::Base()’ is protected within this context
11 | Derived d;
| ^
test.ii:3:5: note: declared protected here
3 | Base();
| ^~~~
The error is emitted for any standard from c++11 to c++2a. No optimization or
other flags are needed.
The same code is compiled without any errors by gcc 9.2.1. Testing on
godbolt.org shows that all other compilers accept it - all recent versions of
clang, msvc, icc.
I don't see any relevant changes mentioned in the GCC 10 release notes
https://gcc.gnu.org/gcc-10/changes.html
An inline implementation of the protected constructor fails too:
class Base {
protected:
Base() {}
};
class Derived : public Base {
public:
using Base::Base;
};
Derived d;
However, the code compiles with the default constructor:
class Base {
protected:
Base() = default;
};
class Derived : public Base {
public:
using Base::Base;
};
Derived d;
More information about the Gcc-bugs
mailing list