[Bug c++/71527] wrong type mismatch while template argument deduction/substitution
benni.buch at gmail dot com
gcc-bugzilla@gcc.gnu.org
Wed Jun 15 17:59:00 GMT 2016
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71527
--- Comment #1 from Benjamin Buch <benni.buch at gmail dot com> ---
I simplified the example code:
//==================== Example ==================
// A compile time int-type
template < int I >
struct size{};
// The problem:
template < typename T, int N >
void f(size< N >, T(&&)[N]){}
int main(){
// OK: T is int
f(size< 2 >(), {0, 1});
// Bug: wrong type mismatch, T should be float
f< float >(size< 2 >(), {0, 1});
// OK: error conflicting types
/* f(size< 2 >(), {0, 1.f}); */
// Bug: wrong type mismatch, T should be float
f< float >(size< 2 >(), {0, 1.f});
}
//===============================================
~$ g++ -o main -std=c++14 main.cpp
bug.cpp: In function ‘int main()’:
bug.cpp:16:32: error: no matching function for call to ‘f(size<2>,
<brace-enclosed initializer list>)’
f< float >(size< 2 >(), {0, 1});
^
bug.cpp:8:6: note: candidate: template<class T, int N> void f(size<N>, T
(&&)[N])
void f(size< N >, T(&&)[N]){}
^
bug.cpp:8:6: note: template argument deduction/substitution failed:
bug.cpp:16:32: note: mismatched types ‘float’ and ‘int’
f< float >(size< 2 >(), {0, 1});
^
bug.cpp:22:34: error: no matching function for call to ‘f(size<2>,
<brace-enclosed initializer list>)’
f< float >(size< 2 >(), {0, 1.f});
^
bug.cpp:8:6: note: candidate: template<class T, int N> void f(size<N>, T
(&&)[N])
void f(size< N >, T(&&)[N]){}
^
bug.cpp:8:6: note: template argument deduction/substitution failed:
bug.cpp:22:34: note: mismatched types ‘float’ and ‘int’
f< float >(size< 2 >(), {0, 1.f});
^
More information about the Gcc-bugs
mailing list