Bug 12630 - gdb is picky on method constness in overload resolution
Summary: gdb is picky on method constness in overload resolution
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: 2011-04-01 16:21 UTC by Pedro Alves
Modified: 2013-10-31 19:31 UTC (History)
1 user (show)

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 Pedro Alves 2011-04-01 16:21:19 UTC
With:

struct base
{
  int overload (void) const { return 0; } // base::overload(void) const
  int overload (int) const { return 0; } // base::overload(int) const
};

int
main (int argc, char* argv[])
{
  base a;
  (void) a.overload ();
  (void) a.overload (1);

  return 0;
}

Listing the (void) variant without the `const' fails:

 (gdb) list 'base::overload()'
 the class `base' does not have any method instance named overload()

With `const', it succeeds:

 (gdb) list  'base::overload() const' 
 1       struct base
 2       {
 3         int overload (void) const { return 0; } // base::overload(void) const
 4         int overload (int) const { return 0; } // base::overload(int) const
 5       };

Since there's no ambiguity, gdb could pick the const variant without the explicit `const'.

This affects "break" and "print" similarly.

Interestingly, if you drop all but one of the overloads (hence, no overloads)
gdb ignores all the prototype arguments you specify, and always finds something:

(gdb) list 'base::overload'
1       struct base
...
(gdb) list 'base::overload()'
1       struct base
...
(gdb) list 'base::overload(asdf1234)'
1       struct base
...
(gdb) list 'base::overload(?????)'
1       struct base
...
Comment 1 Pedro Alves 2011-04-01 17:52:21 UTC
I was pointed out that "print" is already lax if not quoted:

(gdb) p base::overload(void)
$3 = {int (const base * const)} 0x4005c8 <base::overload() const>
(gdb) p 'base::overload(void)'
No symbol "base::overload(void)" in current context.

(gdb) p base::overload(int)
$5 = {int (const base * const, int)} 0x4005d8 <base::overload(int) const>
(gdb) p 'base::overload(int)'
No symbol "base::overload(int)" in current context.
(gdb) 

While list and break aren't.  linespecs vs expressions.