Reputation: 1235
The code below gives me a compilation error.
$ cl.exe VC14-bug.cpp
Microsoft (R) C/C++ Optimizing Compiler Version 19.00.23026 for x64
Copyright (C) Microsoft Corporation. All rights reserved.
VC14-bug.cpp
VC14-bug.cpp(41): error C2893: Failed to specialize function template 'void fails(T1,Poly> *)'
VC14-bug.cpp(41): note: With the following template arguments:
VC14-bug.cpp(41): note: 'T1=int'
VC14-bug.cpp(41): note: 'T2=Kernel'
It is the function f() which poses a problem. Can anybody reproduce it?
template <typename T>
struct Container
{};
struct Kernel {
typedef int Nested;
};
template <class K,
class C = Container<typename K::Nested*> >
struct Poly
{};
// if f() gets commented it compiles
template<class T>
Poly<T>*
f()
{
return 0;
}
//template<class T2, class T1> // this compiles
template<class T1, class T2>
void
fails(T1,
Poly<T2> *)
{}
// if f() is moved here it also compiles
int main()
{
Poly<Kernel> * poly = 0;
fails(0, poly);
return 0;
}
Upvotes: 0
Views: 340
Reputation: 6294
That is certainly a bug in the template parameters deduction code of VC14.
One possible workaround is to allow all types of containers for Poly
, in fails
:
template<class T1, class T2, class Cont>
void
fails(T1,
Poly<T2, Cont> *)
{}
I have verified using online Visual C++ compiler. Unfortunately, one cannot link to test cases like what we would do on Ideone.com (click to see the compilation with g++-5.1).
Upvotes: 1