User account creation filtered due to spam.
Derived classes may access protected members of their base class only on themselves or other instances of the same type or derived type. Here is a link to the relevant section in the draft of the C++ standard:
I don't have access to the actual standard, but I figure you do :-).
The bug occurs when the protected member is a template member function. If the protected member is a simple data member the code fails to compile as it should.
BTW, VC++ 2005 catches this bug and refuses to compile the test program.
Test Program (bug.cpp)
template <typename T>
struct D : public B
D(B * b)
//x = b->x; // fails to compile (correct)
x = b->getX<int>(); // doesn't fail to compile (bug)
int main (int argc, char * const argv)
Output of gcc -v
Using built-in specs.
Configured with: ../src/gcc-4.0.2/configure : (reconfigured) ../src/gcc-4.0.2/configure
Thread model: posix
gcc version 4.0.2
g++ -Wall bug.cpp -o bug
Confirmed, a regression apparently introduced in 3.4.x.
Change target milestone to 4.2.3, as 4.2.2 has been released.
4.2.3 is being released now, changing milestones of open bugs to 4.2.4.
4.2.4 is being released, changing milestones to 4.2.5.
Closing 4.1 branch.
There is a patch here:
Subject: Bug 32519
Date: Fri Nov 28 22:24:49 2008
New Revision: 142264
* g++.dg/template/pr32519.C: New test.
Fixed a while back; ChangeLog entry had wrong PR number.