Is this overload resolution ambiguity correct?

90 views
Skip to first unread message

Andrzej Krzemieński

unread,
Oct 16, 2017, 8:37:41 AM10/16/17
to ISO C++ Standard - Discussion
Hi Everyone,
The following code fails to compile in gcc 7, in C++17 mode (call to f(s) is ambiguous):

template <class T, class U = int>
   
class C
   
{};

template <class T, class U>
   
void f(const C<T, U>&) {}

template <class T, template <class> class CT>
   
void f(CT<T>) {}

int main()
{
    C
<int> s;
    f
(s);
}

It does not fail in C++14, nor does it fail in clang.

I wonder if this is a bug in GCC or clang, or if the standard gives  implementers freedom here.

Regards,
&rzej;

Tom Honermann

unread,
Oct 16, 2017, 11:30:45 AM10/16/17
to std-dis...@isocpp.org
This is CWG issue 150 [1] and was resolved, I believe, by P0522R0 [2].

Tom.

[1]: http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#150
[2]: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0522r0.html
Reply all
Reply to author
Forward
0 new messages