[Bug libstdc++/126427] New: Pair comparisons assume same types

asdfsddf1 at outlook dot com via Gcc-bugs <[email protected]>
Newsgroups gmane.comp.gcc.bugs
Message-ID <[email protected]/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=126427

            Bug ID: 126427
           Summary: Pair comparisons assume same types
           Product: gcc
           Version: 15.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: asdfsddf1 at outlook dot com
  Target Milestone: ---

Created attachment 65138
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=65138&action=edit
The compiler fails with no match for operator== of pair<long long, int> and
pair<int, long long>

According to https://en.cppreference.com/cpp/utility/pair/operator_cmp,

std::pair has comparison for different types in a pair, so logically this code
should compile:
```
#include <utility>
#include <iostream>

int main() {
    std::pair<long long, int> a{1LL, 2};
    std::pair<int, long long> b{1, 2LL};

    std::cout << (a == b); // OK, prints 1
}
```

For reference, MSVC and clang (with libc++) compiles fine with C++14, while g++
using the libstdc++ version tested does not provide the C++14 heterogeneous
std::pair comparison overloads, while other standard library implementations
do. (https://godbolt.org/z/T9efnn9zW)

I have attached the preprocessed source file just in case.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.