🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.g++.bug
Article #1209

G++ 2.3.1 bug: operator[] returns bizarrely behaving type?

#1209
From: Dan R. Greening
Date: Mon, 16 Nov 1992 02:43
40 lines
1251 bytes
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
Technical Details
Message-ID: <1992Nov16.024312.8571@cs.ucla.edu>
Path: arc1-ca.pugleaf.net!sparky!uunet!convex!darwin.sura.net!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!cs.ucla.edu!dgreen

Show Full Headers
Complete Article Headers
Newsgroups: gnu.g++.bug
Path: arc1-ca.pugleaf.net!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