[Bug c++/16246] [3.3/3.4/3.5 regression] Incorrect template argument deduction

bangerth at dealii dot org gcc-bugzilla@gcc.gnu.org
Mon Jun 28 17:23:00 GMT 2004


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



More information about the Gcc-bugs mailing list