With gcc 16, defaulting to c++20, and test-case gdb.cp/cmpd-minsyms.exp I run
into:
...
cmpd-minsyms.cc: In function 'int main(int, char**)':^M
cmpd-minsyms.cc:39:13: warning: C++20 says that these are ambiguous, even \
though the second is reversed:^M
39 | if (a == b)^M
| ^^M
cmpd-minsyms.cc:26:8: note: candidate 1: 'int GDB<T>::operator==(const GDB<T>&) [with T = int]'^M
26 | int operator == (GDB const& other)^M
| ^~~~~~~~^M
cmpd-minsyms.cc:26:8: note: candidate 2: 'int GDB<T>::operator==(const GDB<T>&) [with T = int]' (reversed)^M
cmpd-minsyms.cc:26:8: note: try making the operator a 'const' member function^M
...
Fix this by following the advice:
...
- int operator == (GDB const& other)
+ int operator == (GDB const& other) const
{ return 1; }
...
Likewise in gdb.cp/many-args.exp.
Reviewed-By: Keith Seitz <keiths@redhat.com>
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=34187
static int harder (T a) { return 1; }
template <typename X>
static X even_harder (T a) { return static_cast<X> (a); }
- int operator == (GDB const& other)
+ int operator == (GDB const& other) const
{ return 1; }
void a (void) const { }
void b (void) volatile { }
# of the minimal symbol.
set min_syms [list \
"GDB<int>::operator ==" \
- "GDB<int>::operator==(GDB<int> const&)" \
+ "GDB<int>::operator==(GDB<int> const&) const" \
"GDB<char>::harder(char)" \
"GDB<int>::harder(int)" \
{"int GDB<char>::even_harder<int>(char)"} \
unsigned char aa;
- bool operator== (const ss &rhs)
+ bool operator== (const ss &rhs) const
{
return (memcmp (&this->static_field, &rhs.static_field,
sizeof (this->static_field)) == 0