Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!uunet!brunix!sdm From: sdm@cs.brown.edu (Scott Meyers) Newsgroups: comp.lang.c++ Subject: Bug in CC 2.0? Message-ID: <21932@brunix.UUCP> Date: 30 Nov 89 23:38:47 GMT Sender: news@brunix.UUCP Reply-To: sdm@cs.brown.edu (Scott Meyers) Organization: Brown University Department of Computer Science Lines: 29 Consider the following program: #include enum Node_Type { stuff }; ostream& operator<<(ostream& s, const Node_Type& n); class Node { public: int x; }; void foo(Node& n) { cout << n.x; } When I try to compile it on a Sun Sparcstation with AT&T's 2.0 compiler, this is what I get: CC -c -g +p bug.C -o bug.o CC +p bug.C: "bug.C", line 9: error: int assigned to enum Node_Type 1 error The error is caused by the "cout << n.x" statement. Since n.x is an int, operator<< for int should be called, so I can't imagine why CC is trying to convert it to a Node_Type. If I comment out my definition of operator<< for Node_Type, everything is fine. Is this a bug in CC, or have I done something wrong? Scott sdm@cs.brown.edu