[Bug c++/19741] suboptimal error message for template functions (as opposed to non-templates)

2018-04-23 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=19741

Jonathan Wakely  changed:

   What|Removed |Added

   Last reconfirmed|2006-01-15 21:09:27 |2018-4-23

--- Comment #7 from Jonathan Wakely  ---
Reduced to remove the irrelevant parts and demonstrate the difference between
calls to non-template and temploid functions:

template void Func( T ) { }

typedef bool (*op_func)( int );

void Exec( op_func ) { }

template
struct Op
{
  static void Exec( op_func ) { }
};

int main( )
{
  Exec(  );
  Op::Exec(  );
}

t.cc:17:20: error: no matches converting function 'Func' to type 'op_func' {aka
'bool (*)(int)'}
   Exec(  );
^
t.cc:1:27: note: candidate is: 'template void Func(T)'
 template void Func( T ) { }
   ^~~~
t.cc:18:29: error: no matching function for call to 'Op::Exec()'
   Op::Exec(  );
 ^
t.cc:10:15: note: candidate: 'static void Op::Exec(op_func) [with T = int;
op_func = bool (*)(int)]'
   static void Exec( op_func ) { }
   ^~~~
t.cc:10:15: note:   no known conversion for argument 1 from '' to 'op_func' {aka 'bool (*)(int)'}

[Bug c++/19741] suboptimal error message for template functions (as opposed to non-templates)

2012-01-19 Thread pinskia at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19741

--- Comment #6 from Andrew Pinski pinskia at gcc dot gnu.org 2012-01-20 
02:56:03 UTC ---
We get on the trunk:
t.cc: In function ‘int main()’:
t.cc:21:33: error: no matching function for call to ‘Opint::Exec(int,
unresolved overloaded function type)’
t.cc:21:33: note: candidate is:
t.cc:13:14: note: static bool OpT::Exec(T, OpT::op_func) [with T = int;
OpT::op_func = bool (*)(int)]
t.cc:13:14: note:   no known conversion for argument 2 from ‘unresolved
overloaded function type’ to ‘Opint::op_func {aka bool (*)(int)}’
t.cc: In instantiation of ‘static bool OpT::Exec(T, OpT::op_func) [with T =
int; OpT::op_func = bool (*)(int)]’:
t.cc:21:11:   required from here
t.cc:15:25: warning: cast to pointer from integer of different size
[-Wint-to-pointer-cast]


[Bug c++/19741] suboptimal error message for template functions (as opposed to non-templates)

2005-10-03 Thread pinskia at gcc dot gnu dot org


--- Comment #5 from pinskia at gcc dot gnu dot org  2005-10-04 02:32 ---
The error message was changed by:
Fixed by:
* error.c (dump_type) UNKNOWN_TYPE: Print reworded message.
* g++.dg/overload/unknown1.C: New.

But reading comment 4, that will not fix the issue fully.


-- 


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



[Bug c++/19741] suboptimal error message for template functions (as opposed to non-templates)

2005-02-01 Thread bangerth at dealii dot org

--- Additional Comments From bangerth at dealii dot org  2005-02-01 14:27 
---
This is in fact true. There is a mismatch between error messages for 
template function arguments and non-templates: 
 
void foo1(); 
template typename void foo2(); 
 
template typename bool bar(void (*) () ); 
 
bool b1 = barint (1, foo1); 
bool b2 = barint (1, foo2int); 
 
g/x /home/bangerth/bin/gcc-4.0-pre/bin/c++ -c x.cc 
x.cc:6: error: no matching function for call to ?bar(int, void (*)())? 
x.cc:7: error: no matching function for call to ?bar(int, unknown type)? 
 
Since the complete template arguments to foo2 are given, the type should 
in fact be completely known. 
 
W. 

-- 
   What|Removed |Added

 Status|UNCONFIRMED |NEW
 Ever Confirmed||1
   Keywords||diagnostic
   Last reconfirmed|-00-00 00:00:00 |2005-02-01 14:27:13
   date||
Summary|less than optimal error |suboptimal error message for
   |message (actually, just |template functions (as
   |appears wrong, use of   |opposed to non-templates)
   |unknown_type?)|


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


[Bug c++/19741] suboptimal error message for template functions (as opposed to non-templates)

2005-02-01 Thread gdr at integrable-solutions dot net

--- Additional Comments From gdr at integrable-solutions dot net  
2005-02-01 16:04 ---
Subject: Re:  suboptimal error message for template functions (as opposed to 
non-templates)

bangerth at dealii dot org [EMAIL PROTECTED] writes:

| This is in fact true. There is a mismatch between error messages for 
| template function arguments and non-templates: 
|  
| void foo1(); 
| template typename void foo2(); 
|  
| template typename bool bar(void (*) () ); 
|  
| bool b1 = barint (1, foo1); 
| bool b2 = barint (1, foo2int); 
|  
| g/x /home/bangerth/bin/gcc-4.0-pre/bin/c++ -c x.cc 
| x.cc:6: error: no matching function for call to ?bar(int, void (*)())? 
| x.cc:7: error: no matching function for call to ?bar(int, unknown type)? 
|  
| Since the complete template arguments to foo2 are given, the type should 
| in fact be completely known. 

Agreed.

(More generally, I think the C++ front-end should have a type for
overload set and -- by means of implication for templates too -- to
better capture user mistakes.)

-- Gaby


-- 


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


[Bug c++/19741] suboptimal error message for template functions (as opposed to non-templates)

2005-02-01 Thread bangerth at dealii dot org

--- Additional Comments From bangerth at dealii dot org  2005-02-01 17:30 
---
Except that, of course, in the present case the overload set contains 
only a single function (foo2 isn't overloaded, and we have specified 
all template arguments). Which should make it even easier to handle 
this particular case. 
 
W. 

-- 


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