>Number: 9061 >Category: c++ >Synopsis: Improper access granted to protected typedef from nested member of derived class >Confidential: no >Severity: serious >Priority: medium >Responsible: unassigned >State: open >Class: sw-bug >Submitter-Id: net >Arrival-Date: Thu Dec 26 12:46:01 PST 2002 >Closed-Date: >Last-Modified: >Originator: chris@pennasoft.com >Release: 2.95.4 >Organization: >Environment: FreeBSD topperwein.pennasoft.com 4.7-STABLE FreeBSD 4.7-STABLE #0: Wed Dec 4 15:59:17 EST 2002 behanna@topperwein.pennasoft.com:/raid0/stable/usr/obj/raid0/stable/usr/src/sys/TOPPERWEIN i386 >Description: Consider the following: class Parent { protected: typedef int MyInt; }; class Child: public Parent { protected: class Nested { public: inline MyInt myfunc() { return 0; } }; }; class Nested is not a derived class of class Parent, and thus should not have access to any protected members of class Parent, per the 1997 C++ draft standard, section 11.8, paragraph 1 (see http://anubis.dkuug.dk/jtc1/sc22/open/n2356/access.html ). g++ version 2.95.4 allows the above construct. By way of contrast, Sun's Forté C++ compiler, version 6.2, does not, and issues the complaint: "prot.C", line 10: Error: Parent::MyInt is not accessible from Child::Nested. 1 Error(s) detected. >How-To-Repeat: Save the code example as prot.C and compile it as follows: g++ -c prot.C >Fix: >Release-Note: >Audit-Trail: >Unformatted: