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

            Bug ID: 122550
           Summary: template friend function is ambiguous with g++ 14
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: fujii.hironori at gmail dot com
  Target Milestone: ---

Created attachment 62705
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=62705&action=edit
repro

g++ 13 and clang can compile.
g++ 14 and 15 can't compile.

$ g++ -std=c++23 -c a.cpp
a.cpp: In function ‘void add(Hasher&, UnsignedInteger)’:
a.cpp:21:8: error: call of overloaded ‘add(Hasher&, uint32_t)’ is ambiguous
[-Wtemplate-body]
   21 |     add(hasher, static_cast<uint32_t>(integer));
      |     ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cpp:21:8: note: there are 3 candidates
a.cpp:8:6: note: candidate 1: ‘void add(Hasher&, UnsignedInteger) [with
UnsignedInteger = unsigned int]’
    8 | void add(Hasher&, UnsignedInteger);
      |      ^~~
a.cpp:13:17: note: candidate 2: ‘void add(Hasher&, UnsignedInteger) [with
UnsignedInteger = unsigned int]’
   13 |     friend void add(Hasher& hasher, UnsignedInteger integer) {
      |                 ^~~


https://godbolt.org/z/4aW41Phbh

Reply via email to