This is the mail archive of the gdb-prs@sourceware.org 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]

[Bug c++/12630] New: gdb is picky on method constness in overloadresolution


http://sourceware.org/bugzilla/show_bug.cgi?id=12630

           Summary: gdb is picky on method constness in overload
                    resolution
           Product: gdb
           Version: HEAD
            Status: NEW
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned@sourceware.org
        ReportedBy: pedro@codesourcery.com


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
...

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


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