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

* [Bug c++/16246] Incorrect template argument deduction
  2004-06-28 14:19 [Bug c++/16246] New: Incorrect template argument deduction vassili_bourdo at softhome dot net
@ 2004-06-28 14:37 ` vassili_bourdo at softhome dot net
  2004-06-28 16:29 ` pinskia at gcc dot gnu dot org
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: vassili_bourdo at softhome dot net @ 2004-06-28 14:37 UTC (permalink / raw)
  To: gcc-bugs



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
      Known to fail|                            |3.4.0


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16246


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

* [Bug c++/16246] Incorrect template argument deduction
  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
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-06-28 16:29 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-06-28 16:25 -------
Confirmed.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|                            |1
           Keywords|                            |rejects-valid
      Known to fail|3.4.0                       |3.4.0 3.3.3 3.2.3 3.0.4
                   |                            |2.95.3
   Last reconfirmed|0000-00-00 00:00:00         |2004-06-28 16:25:12
               date|                            |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16246


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

* [Bug c++/16246] [3.3/3.4/3.5 regression] Incorrect template argument deduction
  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 ` bangerth at dealii dot org
  2004-08-18  1:48 ` mmitchel at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: bangerth at dealii dot org @ 2004-06-28 17:23 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From bangerth at dealii dot org  2004-06-28 17:09 -------
Confirmed indeed. This is a rather peculiar failure: 
---------------- 
template <typename T> void foo (T, T); 
 
template <unsigned N, unsigned M>  
int bar( const char(&val)[M] ) 
{ 
  foo (N,M); 
} 
 
int i = bar<10>("1234"); 
---------------- 
 
g/x> /home/bangerth/bin/gcc-3.4-pre/bin/c++ -c x.cc 
x.cc: In function `int bar(const char (&)[M]) [with unsigned int N = 10u, 
unsigned int M = 5]': 
x.cc:9:   instantiated from here 
x.cc:6: error: no matching function for call to `foo(unsigned int, int)' 
 
Note that both N and M are declared to be of type unsigned. However, only 
N is explicitly specified and M is deduced. From the error message, we 
see that M is assumed to be unsigned, but the value given in the template 
parameter list doesn't have the 'u' suffix, so it looks like as if gcc 
knows that the type is unsigned, but that the node in which the actual 
value is stored is a signed integer. This mismatch then causes the failure 
of not finding an instance of foo(). 
 
This used to work in 2.95, so is a regression. 
 
W. 

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
      Known to fail|3.4.0 3.3.3 3.2.3 3.0.4     |3.4.0 3.3.3 3.2.3 3.0.4
                   |2.95.3                      |
      Known to work|                            |2.95.3
            Summary|Incorrect template argument |[3.3/3.4/3.5 regression]
                   |deduction                   |Incorrect template argument
                   |                            |deduction
   Target Milestone|---                         |3.4.2


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16246


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

* [Bug c++/16246] [3.3/3.4/3.5 regression] Incorrect template argument deduction
  2004-06-28 14:19 [Bug c++/16246] New: Incorrect template argument deduction vassili_bourdo at softhome dot net
                   ` (2 preceding siblings ...)
  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
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: mmitchel at gcc dot gnu dot org @ 2004-08-18  1:48 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From mmitchel at gcc dot gnu dot org  2004-08-18 01:48 -------
Working on a fix.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |mark at codesourcery dot com
                   |dot org                     |
             Status|NEW                         |ASSIGNED


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16246


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

* [Bug c++/16246] [3.3/3.4/3.5 regression] Incorrect template argument deduction
  2004-06-28 14:19 [Bug c++/16246] New: Incorrect template argument deduction vassili_bourdo at softhome dot net
                   ` (3 preceding siblings ...)
  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
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: cvs-commit at gcc dot gnu dot org @ 2004-08-18  2:55 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From cvs-commit at gcc dot gnu dot org  2004-08-18 02:55 -------
Subject: Bug 16246

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	mmitchel@gcc.gnu.org	2004-08-18 02:55:14

Modified files:
	gcc/cp         : ChangeLog pt.c 
	gcc/testsuite  : ChangeLog 
Added files:
	gcc/testsuite/g++.dg/template: array7.C 

Log message:
	PR c++/16246
	* pt.c (unify): Tidy ARRAY_TYPE handling.  Make sure that non-type
	arguments have the same type as the corresponding parameter.
	
	PR c++/16246
	* g++.dg/template/array7.C: New test.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&r1=1.4280&r2=1.4281
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/pt.c.diff?cvsroot=gcc&r1=1.906&r2=1.907
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.4153&r2=1.4154
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/array7.C.diff?cvsroot=gcc&r1=NONE&r2=1.1



-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16246


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

* [Bug c++/16246] [3.3/3.4/3.5 regression] Incorrect template argument deduction
  2004-06-28 14:19 [Bug c++/16246] New: Incorrect template argument deduction vassili_bourdo at softhome dot net
                   ` (4 preceding siblings ...)
  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
  7 siblings, 0 replies; 9+ messages in thread
From: cvs-commit at gcc dot gnu dot org @ 2004-08-18  3:00 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From cvs-commit at gcc dot gnu dot org  2004-08-18 03:00 -------
Subject: Bug 16246

CVSROOT:	/cvs/gcc
Module name:	gcc
Branch: 	gcc-3_4-branch
Changes by:	mmitchel@gcc.gnu.org	2004-08-18 02:59:58

Modified files:
	gcc/cp         : ChangeLog pt.c 
	gcc/testsuite  : ChangeLog 
Added files:
	gcc/testsuite/g++.dg/template: array7.C 

Log message:
	PR c++/16246
	* pt.c (unify): Tidy ARRAY_TYPE handling.  Make sure that non-type
	arguments have the same type as the corresponding parameter.
	
	PR c++/16246
	* g++.dg/template/array7.C: New test.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.3892.2.146&r2=1.3892.2.147
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/pt.c.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.816.2.38&r2=1.816.2.39
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.3389.2.249&r2=1.3389.2.250
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/array7.C.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=NONE&r2=1.1.2.1



-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16246


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

* [Bug c++/16246] [3.3/3.4/3.5 regression] Incorrect template argument deduction
  2004-06-28 14:19 [Bug c++/16246] New: Incorrect template argument deduction vassili_bourdo at softhome dot net
                   ` (5 preceding siblings ...)
  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
  7 siblings, 0 replies; 9+ messages in thread
From: mmitchel at gcc dot gnu dot org @ 2004-08-18  3:00 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From mmitchel at gcc dot gnu dot org  2004-08-18 03:00 -------
Fixed in GCC 3.4.2.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16246


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

* [Bug c++/16246] [3.3/3.4/3.5 regression] Incorrect template argument deduction
  2004-06-28 14:19 [Bug c++/16246] New: Incorrect template argument deduction vassili_bourdo at softhome dot net
                   ` (6 preceding siblings ...)
  2004-08-18  3:00 ` mmitchel at gcc dot gnu dot org
@ 2004-08-29 14:54 ` gdr at integrable-solutions dot net
  7 siblings, 0 replies; 9+ messages in thread
From: gdr at integrable-solutions dot net @ 2004-08-29 14:54 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From gdr at integrable-solutions dot net  2004-08-29 14:54 -------
Subject: Re:  [3.3/3.4/3.5 regression] Incorrect template argument deduction

"cvs-commit at gcc dot gnu dot org" <gcc-bugzilla@gcc.gnu.org> writes:

| Subject: Bug 16246
| 
| CVSROOT:	/cvs/gcc
| Module name:	gcc
| Branch: 	gcc-3_4-branch
| Changes by:	mmitchel@gcc.gnu.org	2004-08-18 02:59:58

Will not fix this in 3.3.x series -- even though we have a patch for
3.4.x. 

-- Gaby


-- 


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).