public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/19741] suboptimal error message for template functions (as opposed to non-templates)
[not found] <bug-19741-4@http.gcc.gnu.org/bugzilla/>
@ 2012-01-20 3:16 ` pinskia at gcc dot gnu.org
0 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu.org @ 2012-01-20 3:16 UTC (permalink / raw)
To: gcc-bugs
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 ‘Op<int>::Exec(int,
<unresolved overloaded function type>)’
t.cc:21:33: note: candidate is:
t.cc:13:14: note: static bool Op<T>::Exec(T, Op<T>::op_func) [with T = int;
Op<T>::op_func = bool (*)(int)]
t.cc:13:14: note: no known conversion for argument 2 from ‘<unresolved
overloaded function type>’ to ‘Op<int>::op_func {aka bool (*)(int)}’
t.cc: In instantiation of ‘static bool Op<T>::Exec(T, Op<T>::op_func) [with T =
int; Op<T>::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]
^ permalink raw reply [flat|nested] 5+ messages in thread
[parent not found: <bug-19741-3255@http.gcc.gnu.org/bugzilla/>]
* [Bug c++/19741] New: less than optimal error message (actually, just appears wrong, use of <unknown_type>?)
@ 2005-02-01 14:06 eda-qa at disemia dot com
2005-02-01 14:27 ` [Bug c++/19741] suboptimal error message for template functions (as opposed to non-templates) bangerth at dealii dot org
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: eda-qa at disemia dot com @ 2005-02-01 14:06 UTC (permalink / raw)
To: gcc-bugs
(Such an error also appears to exist in 5458)
In the attached example the following error appears:
tpladdr.cc: In function `int main()':
tpladdr.cc:21: error: no matching function for call to `Op<int>::Exec(int,
<unknown type>)'
tpladdr.cc:14: error: candidates are: static bool Op<T>::Exec(T, bool (*)(T))
[with T = int]
In this case the error does not help (actually it misleads) as to what the
problem is. The reference to <unknown_type> seems to indicate that it doesn't
know the type of that paremeter, when in indeed it actually does, but the
function type has the wrong signature...
Simply correcting the function signature to:
bool Func( T param )
Allows the program to work as it should.
Thus the error message is simply very confusing.
--
Summary: less than optimal error message (actually, just appears
wrong, use of <unknown_type>?)
Product: gcc
Version: 3.3.1
Status: UNCONFIRMED
Severity: minor
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: eda-qa at disemia dot com
CC: gcc-bugs at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19741
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/19741] suboptimal error message for template functions (as opposed to non-templates)
2005-02-01 14:06 [Bug c++/19741] New: less than optimal error message (actually, just appears wrong, use of <unknown_type>?) eda-qa at disemia dot com
@ 2005-02-01 14:27 ` bangerth at dealii dot org
2005-02-01 16:05 ` gdr at integrable-solutions dot net
2005-02-01 17:30 ` bangerth at dealii dot org
2 siblings, 0 replies; 5+ messages in thread
From: bangerth at dealii dot org @ 2005-02-01 14:27 UTC (permalink / raw)
To: gcc-bugs
------- 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 = bar<int> (1, &foo1);
bool b2 = bar<int> (1, &foo2<int>);
--------------------
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|0000-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
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/19741] suboptimal error message for template functions (as opposed to non-templates)
2005-02-01 14:06 [Bug c++/19741] New: less than optimal error message (actually, just appears wrong, use of <unknown_type>?) eda-qa at disemia dot com
2005-02-01 14:27 ` [Bug c++/19741] suboptimal error message for template functions (as opposed to non-templates) bangerth at dealii dot org
@ 2005-02-01 16:05 ` gdr at integrable-solutions dot net
2005-02-01 17:30 ` bangerth at dealii dot org
2 siblings, 0 replies; 5+ messages in thread
From: gdr at integrable-solutions dot net @ 2005-02-01 16:05 UTC (permalink / raw)
To: gcc-bugs
------- 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" <gcc-bugzilla@gcc.gnu.org> 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 = bar<int> (1, &foo1);
| bool b2 = bar<int> (1, &foo2<int>);
| --------------------
| 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
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/19741] suboptimal error message for template functions (as opposed to non-templates)
2005-02-01 14:06 [Bug c++/19741] New: less than optimal error message (actually, just appears wrong, use of <unknown_type>?) eda-qa at disemia dot com
2005-02-01 14:27 ` [Bug c++/19741] suboptimal error message for template functions (as opposed to non-templates) bangerth at dealii dot org
2005-02-01 16:05 ` gdr at integrable-solutions dot net
@ 2005-02-01 17:30 ` bangerth at dealii dot org
2 siblings, 0 replies; 5+ messages in thread
From: bangerth at dealii dot org @ 2005-02-01 17:30 UTC (permalink / raw)
To: gcc-bugs
------- 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
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2012-01-20 2:56 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <bug-19741-4@http.gcc.gnu.org/bugzilla/>
2012-01-20 3:16 ` [Bug c++/19741] suboptimal error message for template functions (as opposed to non-templates) pinskia at gcc dot gnu.org
[not found] <bug-19741-3255@http.gcc.gnu.org/bugzilla/>
2005-10-04 2:32 ` pinskia at gcc dot gnu dot org
2005-02-01 14:06 [Bug c++/19741] New: less than optimal error message (actually, just appears wrong, use of <unknown_type>?) eda-qa at disemia dot com
2005-02-01 14:27 ` [Bug c++/19741] suboptimal error message for template functions (as opposed to non-templates) bangerth at dealii dot org
2005-02-01 16:05 ` gdr at integrable-solutions dot net
2005-02-01 17:30 ` bangerth at dealii dot org
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).