This is the mail archive of the gdb-prs@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

gdb/804: members of C++ classes are shadowed by static or global vars in the same file


>Number:         804
>Category:       gdb
>Synopsis:       members of C++ classes are shadowed by static or global vars in the same file
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Oct 22 14:28:01 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator:     carlton@math.stanford.edu
>Release:        GNU gdb 2002-10-11-cvs
>Organization:
>Environment:
Linux jackfruit.Stanford.EDU 2.4.18-5 #1 Mon Jun 10 15:31:48 EDT 2002 i686 unknown
gcc (GCC) 3.1
This GDB was configured as "i686-pc-linux-gnu".
>Description:
lookup_symbol_aux() searches the current block and all its
superblocks before doing the is_a_field_of_this stuff.
This means that, if a static or global variable from within the current file has the same name as a field of this, the former will erroneously be found instead of the latter.
>How-To-Repeat:
Compile the following:

#include <iostream>

class C
{
public:
  C (int xval) : x(xval) {}
  int x;
  void marker () { std::cout << x; }
};

static int x = 0;

int main ()
{
  C theC (1);

  theC.marker ();
}

If you run it, it will print out '1'.  But if you break on C::marker and print out x, GDB will claim that it's zero.
>Fix:
Tell lookup_symbol_aux not to read the static block until
after is_a_field_of_this has been taken care of.  I'll
submit a fix once somebody approves my lookup_symbol_aux
refactoring.
>Release-Note:
>Audit-Trail:
>Unformatted:


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]