home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / gnu / g / bug / 1836 next >
Encoding:
Text File  |  1992-11-17  |  1.2 KB  |  54 lines

  1. Newsgroups: gnu.g++.bug
  2. Path: sparky!uunet!convex!darwin.sura.net!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!cs.ucla.edu!dgreen
  3. From: dgreen@cs.ucla.edu (Dan R. Greening)
  4. Subject: G++ 2.3.1 bug: operator[] returns bizarrely behaving type?
  5. Message-ID: <1992Nov16.024312.8571@cs.ucla.edu>
  6. Sender: gnulists@ai.mit.edu
  7. Organization: UCLA, Computer Science Department
  8. Distribution: gnu
  9. Date: Mon, 16 Nov 1992 02:43:12 GMT
  10. Approved: bug-g++@prep.ai.mit.edu
  11. Lines: 41
  12.  
  13. The following program prints out
  14.  
  15.   0x2290
  16.   good things
  17.   most things
  18.  
  19. but I think it should print out
  20.  
  21.   most things
  22.   good things
  23.   most things
  24.  
  25. Here is the program:
  26.  
  27. -------------------------- cut here ------------------
  28. #include <iostream.h>
  29. class thing
  30. {
  31.   public:
  32.     char* const& operator[](const int& b)
  33.     {
  34.     static char* mostthings = "most things";
  35.     return mostthings;
  36.     }
  37. };
  38.  
  39. main()
  40. {
  41.     thing a;
  42.     char * const b = "good things";
  43.     char * const& c = a[3];
  44.     
  45.     cout << a[3] << "\n";        // a[3] and b should be same type
  46.     cout << b << "\n";
  47.     cout << c << "\n";
  48. }
  49. -- 
  50. ____
  51. \  /Dan Greening    Software Transformation      1601 Saratoga-Sunnyvale Rd
  52.  \/ dgreen@cs.ucla.edu    (408) 973-8081 x313      Cupertino, CA 95014
  53.  
  54.