https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66957
Bug ID: 66957
Summary: irregular "is protected within this context" error
Product: gcc
Version: 5.1.0
Status: UNCONFIRMED
Severity: major
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: dreamcooled at gmail dot com
Target Milestone: ---
Created attachment 36023
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=36023&action=edit
The code which produces the bug
In the attachment you find code which I'm trying to compile with g++.
I have a archlinux system and I have g++ version 5.1.0 from the offical repo of
my system.
I'm trying to compile the attached code by invoking
`g++ classtest.cpp`.
gcc fires the error:
classtest.cpp: In constructor ‘DerivedB::DerivedB()’:
classtest.cpp:9:5: error: ‘int BaseClass::x’ is protected
int BaseClass::x;
^
classtest.cpp:22:32: error: within this context
std::cout << DerivedA::x;
^
What I'm trying to achieve is completely legal according to the c++ standard
([class.access.base]/p5 ).
More information, discussion, and a lot of people who agree that this is indeed
a gcc bug, can be found in the associated stackoverflow question:
http://stackoverflow.com/questions/31389470/g-compilation-error-is-protected-from-within-this-context-while-clang-do