[Bug c++/78701] New: Template deduction, dependent template and conversion to bool failure
vince.rev at gmail dot com
gcc-bugzilla@gcc.gnu.org
Tue Dec 6 17:31:00 GMT 2016
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78701
Bug ID: 78701
Summary: Template deduction, dependent template and conversion
to bool failure
Product: gcc
Version: 6.1.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: vince.rev at gmail dot com
Target Milestone: ---
The following code fails to compile on g++ 6.1, 6.2, and 7 (and I guess on g++
6.0):
======================================================================
#include <iostream>
template <class T, T N = T(), bool B = N + 1> T f(T x) {return T();}
int main(int argc, char* argv[]) {return f(42);}
======================================================================
It returns the following error:
======================================================================
test_bug.cpp: In function ‘int main(int, char**)’:
test_bug.cpp:3:46: error: no matching function for call to ‘f(int)’
int main(int argc, char* argv[]) {return f(42);}
^
test_bug.cpp:2:49: note: candidate: template<class T, T N, bool B> T f(T)
template <class T, T N = T(), bool B = N + 1> T f(T x) {return T();}
^
test_bug.cpp:2:49: note: template argument deduction/substitution failed:
test_bug.cpp:2:42: error: invalid use of template type parameter ‘T’
template <class T, T N = T(), bool B = N + 1> T f(T x) {return T();}
~~^~~
test_bug.cpp:2:44: error: could not convert template argument ‘<expression
error>’ to ‘bool’
template <class T, T N = T(), bool B = N + 1> T f(T x) {return T();}
^
======================================================================
More information about the Gcc-bugs
mailing list