Bug 15383 - name lookup and dependent bases
Summary: name lookup and dependent bases
Status: NEW
Alias: None
Product: gdb
Classification: Unclassified
Component: c++ (show other bugs)
Version: HEAD
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks: 16106
  Show dependency treegraph
 
Reported: 2013-04-19 18:06 UTC by Tom Tromey
Modified: 2013-10-31 19:45 UTC (History)
0 users

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


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tom Tromey 2013-04-19 18:06:11 UTC
Consider this test case:

int f() { return 23; }

template<typename T>
struct Base {
  int f() { return 13; }
};

template<typename T>
struct Derived : public Base<T> {
  int g() { return f(); }
};

int main()
{
  Derived<int> value;
  return value.g();
}

Here, Derived::g calls ::f, not Base::f.
This is due to a C++ name lookup rule, see:

http://gcc.gnu.org/onlinedocs/gcc/Name-lookup.html
http://gcc.gnu.org/wiki/VerboseDiagnostics#dependent_base

gdb implements this wrongly -- if you stop in g and try to call f,
gdb will try to call Base::f.