This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/16246] New: Incorrect template argument deduction
- From: "vassili_bourdo at softhome dot net" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 28 Jun 2004 14:19:01 -0000
- Subject: [Bug c++/16246] New: Incorrect template argument deduction
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
the code:
-------------------------------------
//#include <algorithm>
namespace std
{
template<class T> T min(T const&,T const&);
//declaring min() instead of including <algorithm> to save
space.
//this example works in both cases
}
template<unsigned N>
struct tester
{
template<class T,unsigned M>
void fn( T(&val)[M] )
{
std::min(N,M);
std::min(M,N);
}
};
int main()
{
tester<10> t;
t.fn("1234");
}
-------------------------------------
fails on mingw GCC-3.4.0 with diagnostics:
-------------------------------------
bug2.cxx: In member function `void tester<N>::fn(T (&)[M]) [with T = const
char, unsigned int M = 5, unsigned int N = 10u]':
bug2.cxx:20: instantiated from here
bug2.cxx:12: error: no matching function for call to `min(unsigned int, int)'
bug2.cxx:13: error: no matching function for call to `min(int, unsigned int)'
-------------------------------------
"M" deduced to be "int", but it declared as "unsigned" in "template<>" clause
--
Summary: Incorrect template argument deduction
Product: gcc
Version: 3.4.0
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: vassili_bourdo at softhome dot net
CC: gcc-bugs at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16246