Bug 96816 - bitset: debug mode: operator== ambiguous
Summary: bitset: debug mode: operator== ambiguous
Status: RESOLVED DUPLICATE of bug 96303
Alias: None
Product: gcc
Classification: Unclassified
Component: libstdc++ (show other bugs)
Version: unknown
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-08-27 12:28 UTC by Jean-Michaël Celerier
Modified: 2020-08-27 12:43 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jean-Michaël Celerier 2020-08-27 12:28:36 UTC
Hello,

Given the following code: 

```
#define _GLIBCXX_DEBUG 1
#include <bitset>

std::bitset<3> a, b;
bool test = (a == b);
```

clang gives the following error: 

```
$ clang++ -c foo.cpp -std=c++20 
In file included from foo.cpp:2:
In file included from /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/10.2.0/../../../../include/c++/10.2.0/bitset:1595:
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/10.2.0/../../../../include/c++/10.2.0/debug/bitset:356:26: error: use of overloaded operator '==' is ambiguous (with operand types 'const std::__debug::bitset<3>::_Base' (aka 'const bitset<3UL>') and 'const bitset<3UL>' (aka 'const std::__debug::bitset<3>'))
      { return _M_base() == __rhs; }
               ~~~~~~~~~ ^  ~~~~~
foo.cpp:5:16: note: in instantiation of member function 'std::__debug::bitset<3>::operator==' requested here
bool test = (a == b);
               ^
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/10.2.0/../../../../include/c++/10.2.0/bitset:1306:7: note: candidate function
      operator==(const bitset<_Nb>& __rhs) const _GLIBCXX_NOEXCEPT
      ^
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/10.2.0/../../../../include/c++/10.2.0/debug/bitset:355:7: note: candidate function (with reversed parameter order)
      operator==(const bitset<_Nb>& __rhs) const _GLIBCXX_NOEXCEPT
      ^
1 error generated
```

g++ does not, but I guess this still warrants checking ?
Comment 1 Jean-Michaël Celerier 2020-08-27 12:29:25 UTC
gcc.godbolt.org link for easy repro: https://gcc.godbolt.org/z/WYbzfT
Comment 2 Jean-Michaël Celerier 2020-08-27 12:30:16 UTC
I'd wager this is a result of C++20 operator<=> changes and operator== synthesis.
Comment 3 Jonathan Wakely 2020-08-27 12:37:33 UTC
Already fixed.

*** This bug has been marked as a duplicate of bug 96303 ***
Comment 4 Jonathan Wakely 2020-08-27 12:43:11 UTC
(In reply to Jean-Michaël Celerier from comment #0)
> g++ does not, but I guess this still warrants checking ?

N.B. GCC does give an error if you compile with -Wpedantic -std=c++20