[Converted from Gnats 2073] Attempting to display the results of a subscript operator call on a reference that has been typedef'ed displays the error "cannot subscript something of type CLASSNAME". This is 100% reproducible in the environments specified. Using either -gdb and -gstabs+ flags makes no difference. Release: unknown Environment: SunOS 5.8 Generic_108528-29 sun4u sparc SUNW,Sun-Fire-V210, gcc-3.4.4/4.0.0, gdb-6.4 How-To-Repeat: The following code demonstrates the error: #include <iostream> class Foo { private: int value; public: Foo( const int val ) { value = val; } int operator[]( const int i ) const { return value; } }; typedef Foo Bar; int main() { Foo foo1( 123 ); std::cout << foo1[ 0 ] << std::endl; // In the debugger, type print foo1[ 0 ]: NO PROBLEM Foo &foo2 = foo1; std::cout << foo2[ 0 ] << std::endl; // In the debugger, type print foo2[ 0 ]: NO PROBLEM Bar &bar1 = foo1; std::cout << bar1[ 0 ] << std::endl; // In the debugger, type print bar1[ 0 ]: ERROR! // cannot subscript something of type `Foo' Bar bar2( 321 ); std::cout << bar2[ 0 ] << std::endl; // In the debugger, type print bar2[ 0 ]: NO PROBLEM return 0; }
Responsible-Changed-From-To: unassigned->jimb Responsible-Changed-Why: I think I know what this is. I sure hope so, or else I'll have to get into the C++ code.
State-Changed-From-To: open->feedback State-Changed-Why: Could you try the attached patch?
From: "Chaudhuri, Soumya" <soumya.chaudhuri@blackrock.com> To: <gdb-gnats@sources.redhat.com> Cc: Subject: Re: varobj/2073: subscript operator on typedef'ed reference fails Date: Tue, 24 Jan 2006 10:44:10 -0500 The patch fixes the issue. Thanks! THE INFORMATION CONTAINED IN THIS MESSAGE AND ANY ATTACHMENT MAY BE PRIVILEGED, CONFIDENTIAL, PROPRIETARY OR OTHERWISE PROTECTED FROM DISCLOSURE. If the reader of this message is not the intended recipient, you are hereby notified that any dissemination, distribution, copying or use of this message and any attachment is strictly prohibited. If you have received this message in error, please notify us immediately by replying to the message and permanently delete it from your computer and destroy any printou t thereof.
State-Changed-From-To: feedback->closed State-Changed-Why: Fix committed to trunk.