[Bug c++/58354] variadic template ambiguous

officesamurai at gmail dot com gcc-bugzilla@gcc.gnu.org
Wed Nov 19 17:21:00 GMT 2014


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

Mikhail Kremnyov <officesamurai at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |officesamurai at gmail dot com

--- Comment #1 from Mikhail Kremnyov <officesamurai at gmail dot com> ---
There is a simpler case.

test.cpp:
template <typename T1, typename T2, typename... Types>
void foo(T2, Types...)
{
}

template <typename T1, typename... Types>
void foo(int, Types...)
{
}

int main()
{
  foo<void>(1, 2);
}

Command line:
g++ -std=c++11 test.cpp -o test

Output:
test.cpp: In function ‘int main()’:
test.cpp:13:17: error: call of overloaded ‘foo(int, int)’ is ambiguous
   foo<void>(1, 2);
                 ^
test.cpp:13:17: note: candidates are:
test.cpp:2:6: note: void foo(T2, Types ...) [with T1 = void; T2 = int; Types =
{int}]
 void foo(T2, Types...)
      ^
test.cpp:7:6: note: void foo(int, Types ...) [with T1 = void; Types = {int}]
 void foo(int, Types...)

I tried this with versions 4.8.1, 4.9.1, 4.9.2 - same result.
Clang has no problems with this code.


More information about the Gcc-bugs mailing list