Bug 9178 - subscript operator on typedef'ed reference fails
Summary: subscript operator on typedef'ed reference fails
Status: CLOSED FIXED
Alias: None
Product: gdb
Classification: Unclassified
Component: varobj (show other bugs)
Version: unknown
: P3 enhancement
Target Milestone: ---
Assignee: Jim Blandy
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-01-23 23:58 IST by schaudhu
Modified: 2008-12-18 20:56 IST (History)
3 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments
jimb.gdb-binop-ref-typedef.patch (834 bytes, application/octet-stream)
, schaudhu
Details

Note You need to log in before you can comment on or make changes to this bug.
Description schaudhu 2006-01-23 23:58:01 IST
[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;
}
Comment 1 Jim Blandy 2006-01-24 07:30:39 IST
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.
Comment 2 Jim Blandy 2006-01-24 07:43:24 IST
State-Changed-From-To: open->feedback
State-Changed-Why: Could you try the attached patch?
Comment 3 soumya.chaudhuri 2006-01-24 15:44:10 IST
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.
Comment 4 Jim Blandy 2006-01-25 06:43:31 IST
State-Changed-From-To: feedback->closed
State-Changed-Why: Fix committed to trunk.