https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103849

            Bug ID: 103849
           Summary: std::hash specializations with distinct concepts fails
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: fchelnokov at gmail dot com
  Target Milestone: ---

The two specialization of std::hash with distinct concepts:
```
#include <concepts>
#include <functional>

template <std::convertible_to<int> T>
struct std::hash<T> {};

template <std::convertible_to<float> U>
struct std::hash<U> {};

int main() {}
```
fails to compile in GCC with the error:
```
error: redefinition of 'struct std::hash<_Tp>'
    8 | struct std::hash<U> {};
```
Clang and MSVC have no problem with it. Demo:
https://gcc.godbolt.org/z/z4f3o6bdo

Related discussion: https://stackoverflow.com/q/68885697/7325599

Reply via email to