[Bug c++/68138] "operator== is ambiguous" when comparing a tuple containing values with one containing refs

2022-01-07 Thread ppalka at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68138

Patrick Palka  changed:

   What|Removed |Added

   See Also||https://gcc.gnu.org/bugzill
   ||a/show_bug.cgi?id=93147
 CC||ppalka at gcc dot gnu.org

--- Comment #5 from Patrick Palka  ---
(In reply to Andrew Pinski from comment #4)
> The original testcase and the one in comment #2 started to work in GCC 11+.

I suspect by r11-2720 aka the fix for PR libstdc++/93147.

(In reply to Harald van Dijk from comment #3)
> Here's a reduced standalone testcase, no libstdc++.
> 
> struct Empty { bool operator==(Empty); };
> class tuple_impl : Empty {};
> class tuple : tuple_impl, Empty {};
> bool operator==(tuple, tuple);
> int main() { tuple a, b; a == b; }
> 
> tuple derives from Empty twice and would inherit its operator==(Empty)
> member function, except any attempt to use it would be ambiguous. GCC and
> Intel reject this, clang and MSVC accept it using the global
> operator==(tuple, tuple). If tuple only inherits from Empty once, then all
> compilers are in agreement that operator==(tuple, tuple) is a better match
> than the operator==(Empty) member function.

IIUC the ambiguous member lookup makes this example ill-formed, despite the
global operator== otherwise being a better candidate than Empty::operator==.

[Bug c++/68138] "operator== is ambiguous" when comparing a tuple containing values with one containing refs

2021-08-04 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68138

--- Comment #4 from Andrew Pinski  ---
The original testcase and the one in comment #2 started to work in GCC 11+.

[Bug c++/68138] "operator== is ambiguous" when comparing a tuple containing values with one containing refs

2019-03-13 Thread harald at gigawatt dot nl
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68138

Harald van Dijk  changed:

   What|Removed |Added

 CC||harald at gigawatt dot nl

--- Comment #3 from Harald van Dijk  ---
Here's a reduced standalone testcase, no libstdc++.

struct Empty { bool operator==(Empty); };
class tuple_impl : Empty {};
class tuple : tuple_impl, Empty {};
bool operator==(tuple, tuple);
int main() { tuple a, b; a == b; }

tuple derives from Empty twice and would inherit its operator==(Empty) member
function, except any attempt to use it would be ambiguous. GCC and Intel reject
this, clang and MSVC accept it using the global operator==(tuple, tuple). If
tuple only inherits from Empty once, then all compilers are in agreement that
operator==(tuple, tuple) is a better match than the operator==(Empty) member
function.

[Bug c++/68138] "operator== is ambiguous" when comparing a tuple containing values with one containing refs

2019-03-13 Thread unsavoryemail at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68138

Alexander Haase  changed:

   What|Removed |Added

 CC||unsavoryemail at gmail dot com

--- Comment #2 from Alexander Haase  ---
Can confirm that this is still an issue up to the latest release of GCC 8.
Here's an even simpler reproduction:

#include 

struct Empty {
bool operator == (const Empty &) const { return true; }
};

int main() {
std::tuple a, b;
return a == b;
}

Here's a compiler explorer example where clang and msvc compile the above with
no issue, but gcc does not. Note that clang and gcc use the same stl
implementation as configured for compiler explorer.

https://godbolt.org/z/Em6B9e

[Bug c++/68138] "operator== is ambiguous" when comparing a tuple containing values with one containing refs

2015-11-11 Thread ville.voutilainen at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68138

--- Comment #1 from Ville Voutilainen  ---
The test works if operator== is not a member. There's something fairly fishy
going on here.

[Bug c++/68138] "operator== is ambiguous" when comparing a tuple containing values with one containing refs

2015-11-11 Thread ville.voutilainen at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68138

Ville Voutilainen  changed:

   What|Removed |Added

 Status|UNCONFIRMED |NEW
   Last reconfirmed||2015-11-11
 CC||ville.voutilainen at gmail dot 
com
 Ever confirmed|0   |1
  Known to fail||4.8.2, 4.9.2, 5.2.0, 6.0