public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/16246] New: Incorrect template argument deduction
@ 2004-06-28 14:19 vassili_bourdo at softhome dot net
  2004-06-28 14:37 ` [Bug c++/16246] " vassili_bourdo at softhome dot net
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: vassili_bourdo at softhome dot net @ 2004-06-28 14:19 UTC (permalink / raw)
  To: gcc-bugs

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


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2004-08-29 14:54 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-06-28 14:19 [Bug c++/16246] New: Incorrect template argument deduction vassili_bourdo at softhome dot net
2004-06-28 14:37 ` [Bug c++/16246] " vassili_bourdo at softhome dot net
2004-06-28 16:29 ` pinskia at gcc dot gnu dot org
2004-06-28 17:23 ` [Bug c++/16246] [3.3/3.4/3.5 regression] " bangerth at dealii dot org
2004-08-18  1:48 ` mmitchel at gcc dot gnu dot org
2004-08-18  2:55 ` cvs-commit at gcc dot gnu dot org
2004-08-18  3:00 ` cvs-commit at gcc dot gnu dot org
2004-08-18  3:00 ` mmitchel at gcc dot gnu dot org
2004-08-29 14:54 ` gdr at integrable-solutions dot net

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).