home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: gnu.g++.bug
- Path: sparky!uunet!convex!darwin.sura.net!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!cs.ucla.edu!dgreen
- From: dgreen@cs.ucla.edu (Dan R. Greening)
- Subject: G++ 2.3.1 bug: operator[] returns bizarrely behaving type?
- Message-ID: <1992Nov16.024312.8571@cs.ucla.edu>
- Sender: gnulists@ai.mit.edu
- Organization: UCLA, Computer Science Department
- Distribution: gnu
- Date: Mon, 16 Nov 1992 02:43:12 GMT
- Approved: bug-g++@prep.ai.mit.edu
- Lines: 41
-
- The following program prints out
-
- 0x2290
- good things
- most things
-
- but I think it should print out
-
- most things
- good things
- most things
-
- Here is the program:
-
- -------------------------- cut here ------------------
- #include <iostream.h>
- class thing
- {
- public:
- char* const& operator[](const int& b)
- {
- static char* mostthings = "most things";
- return mostthings;
- }
- };
-
- main()
- {
- thing a;
- char * const b = "good things";
- char * const& c = a[3];
-
- cout << a[3] << "\n"; // a[3] and b should be same type
- cout << b << "\n";
- cout << c << "\n";
- }
- --
- ____
- \ /Dan Greening Software Transformation 1601 Saratoga-Sunnyvale Rd
- \/ dgreen@cs.ucla.edu (408) 973-8081 x313 Cupertino, CA 95014
-
-