Path: utzoo!utgpu!water!watmath!clyde!bellcore!rutgers!ucsd!ames!sgi!daisy!ronen From: ronen@daisy.UUCP (daisy.ronen) Newsgroups: comp.lang.c++ Subject: g++ bug (version 1.22.1 on sun3 UNIX 4.2 Release 3.5) Keywords: g++,bug Message-ID: <1472@daisy.UUCP> Date: 10 Aug 88 19:18:57 GMT Organization: Daisy Systems, Mt. View, CA Lines: 41 I compiled the following program (taken from The Evolution of C++:1985 to 1987/ Bjarne Stroustrup USENIX proceedings C++ Workshop 1987) to examine the private/protected/public scope handling of g++. The program was compile without any error or warning. The g++ compiler should report errors at the statements commented with error: Here is the program: class X { // private by default int priv; protected: int prot; public: int publ; }; class Y : public X { void mf(); }; void Y::mf() { priv = 1; // error: priv is private prot = 2; // OK: prot is protected and mf() is a member of subclass Y publ = 3; // OK: publ is public } void f(Y* p) { p->priv = 1; // error: priv is private p->prot = 2; // error: prot is protected and f() is not a friend or member of X or Y p->publ = 3; // OK: publ is public } Ronen Arad Daisy Systems (Mnt View, CA) (415) 960-6884 uucp: daisy!ronen