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

--- Comment #4 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Reduced:

namespace N
{
template<typename C>
struct string_view
{
  using char_type = C;
};

template<typename C>
struct string
{
  void operator+=(const string&);

  template<typename T, typename = typename T::char_type>
  void operator+=(const T&);
};

template<typename T>
void f()
{
  string<T> s;
  s += string_view<T>();
}

} // namespace N

template<typename T1, typename T2>
void operator+=(T1&, const T2&){}

int main()
{
  N::f<char>();
}

Clang and EDG compile this, GCC doesn't:

100465.cc: In instantiation of ‘void N::f() [with T = char]’:
100465.cc:32:14:   required from here
100465.cc:22:5: error: ambiguous overload for ‘operator+=’ (operand types are
‘N::string<char>’ and ‘N::string_view<char>’)
   22 |   s += string_view<T>();
      |   ~~^~~~~~~~~~~~~~~~~~~
100465.cc:15:8: note: candidate: ‘void N::string<C>::operator+=(const T&) [with
T = N::string_view<char>; <template-parameter-2-2> = char; C = char]’
   15 |   void operator+=(const T&);
      |        ^~~~~~~~
100465.cc:28:6: note: candidate: ‘void operator+=(T1&, const T2&) [with T1 =
N::string<char>; T2 = N::string_view<char>]’
   28 | void operator+=(T1&, const T2&){}
      |      ^~~~~~~~

Reply via email to