The following test case was accepted in g++-4.3.x and earlier, but rejected by
4.4.0.
Code is possibly invalid, can any standard-fluent experts comment?
// prNEW.cc -- test case
class base {
protected:
void
foo(void) const;
};
class derived : protected base {
public:
void
bar(void) const {
base::foo();
}
};
void
base::foo(void) const {
static_cast<const derived&>(*this);
}
% g++-4 -ansi -pedantic-errors -Wold-style-cast -Woverloaded-virtual -W -Wextra
-Wall -Wundef -Wshadow -Wno-unused-parameter -Wpointer-arith -Wcast-qual
-Wcast-align -Wconversion -Werror -std=c++0x -Wno-error=conversion -g -O3
-Wno-long-long -c prNEW.cc -o prNEW.o
prNEW.cc: In member function 'void base::foo() const':
prNEW.cc:17: error: 'base' is an inaccessible base of 'derived'
VERY closely related to pr12265, the only real change is from private to
protected inherited base.
--
Summary: static downcast through protectedly inherited base class
rejected
Product: gcc
Version: 4.4.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: fang at csl dot cornell dot edu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39905