This is the mail archive of the
gdb-prs@sourceware.org
mailing list for the GDB project.
[Bug c++/16463] New: Global variable/class method name collision
- From: "keiths at redhat dot com" <sourceware-bugzilla at sourceware dot org>
- To: gdb-prs at sourceware dot org
- Date: Fri, 17 Jan 2014 19:22:12 +0000
- Subject: [Bug c++/16463] New: Global variable/class method name collision
- Auto-submitted: auto-generated
https://sourceware.org/bugzilla/show_bug.cgi?id=16463
Bug ID: 16463
Summary: Global variable/class method name collision
Product: gdb
Version: HEAD
Status: NEW
Severity: enhancement
Priority: P2
Component: c++
Assignee: unassigned at sourceware dot org
Reporter: keiths at redhat dot com
Consider the following code:
int global = 1;
class A
{
public:
int global (void) const { return 0; }
};
int
main (void)
{
A a;
return a.global ();
}
(gdb) start
(gdb) p global
$1 = 1 <-- ok
(gdb) b A::global
(gdb) continue
(gdb) p global
$2 = {void (const A * const)} 0x12345678 <A::global() const>
There is a collision between the global variable and the method, and when
stopped in the method of a class, the class method wins the lookup. While it is
likely that the user wanted to inspect the global variable, it is not
altogether unreasonable that he actually did want to know about the method.
However since lookup_symbol returns only a single match, the method is found (a
result of the is_a_field_of_this lookup in lookup_symbol_aux). There is
currently no way to query the user for his intention (unlike method
overloading, where we actually can ask the user).
Fortunately, a simple workaround exists:
(gdb) p ::global
$3 = 1
--
You are receiving this mail because:
You are on the CC list for the bug.