------- Comment #2 from darkwingz at yahoo dot com 2008-08-13 15:57 ------- Thanks for your reply. I think I would have seen this had I tried testing it without the nesting. I tried to compile the following code:
class A { protected: int i; }; class B : public A { public: void foo(A *a) { a->i = 1; } }; And it also did not work. However, if I change the parameter of foo() to a B, then it works. I guess this is to prevent a child class from modifying an instance of type parent, and not type child. It's ok to modify something protected if it's your type, but by making the parameter the type of the parent you can't be sure it's the same child type. (Well, you can with dynamic_cast, but it wouldn't make sense to allow it.) Thanks for the food for thought. I'll cancel the bug. -- darkwingz at yahoo dot com changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |RESOLVED Resolution| |INVALID http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37112