* [Bug c++/40793] "Error: no matching function for call to XYZ" doesn't display function-template-arguments
2009-07-17 22:09 [Bug c++/40793] New: "Error: no matching function for call to XYZ" doesn't display function-template-arguments jonathan dot sd24 at yahoo dot de
@ 2009-07-18 8:59 ` rguenth at gcc dot gnu dot org
2009-07-18 10:02 ` jonathan dot sd24 at yahoo dot de
` (6 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2009-07-18 8:59 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from rguenth at gcc dot gnu dot org 2009-07-18 08:59 -------
But it doens't know it looks for a template function. It should display the
candidate list from which you can see what happens.
This is how name-lookup and overload resolution works...
--
rguenth at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |WONTFIX
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40793
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/40793] "Error: no matching function for call to XYZ" doesn't display function-template-arguments
2009-07-17 22:09 [Bug c++/40793] New: "Error: no matching function for call to XYZ" doesn't display function-template-arguments jonathan dot sd24 at yahoo dot de
2009-07-18 8:59 ` [Bug c++/40793] " rguenth at gcc dot gnu dot org
@ 2009-07-18 10:02 ` jonathan dot sd24 at yahoo dot de
2009-07-21 17:46 ` jwakely dot gcc at gmail dot com
` (5 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: jonathan dot sd24 at yahoo dot de @ 2009-07-18 10:02 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from jonathan dot sd24 at yahoo dot de 2009-07-18 10:02 -------
When I explicitly specify the template-arguments g++ should know it.
And there was no candidate-list.
For example:
template<typename T, T t>
void staticPrint()
{
cout << t << endl;
}
Now I call:
staticPrint<double, "text">();
I get:
"no matching function for call to void staticPrint()"
No candidates... And I would like to know, what's wrong with the
template-arguments.
Beleive me: You can spent hours with searching for the reason of such an error.
--
jonathan dot sd24 at yahoo dot de changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|RESOLVED |UNCONFIRMED
Resolution|WONTFIX |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40793
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/40793] "Error: no matching function for call to XYZ" doesn't display function-template-arguments
2009-07-17 22:09 [Bug c++/40793] New: "Error: no matching function for call to XYZ" doesn't display function-template-arguments jonathan dot sd24 at yahoo dot de
2009-07-18 8:59 ` [Bug c++/40793] " rguenth at gcc dot gnu dot org
2009-07-18 10:02 ` jonathan dot sd24 at yahoo dot de
@ 2009-07-21 17:46 ` jwakely dot gcc at gmail dot com
2009-07-29 21:05 ` jonathan dot sd24 at yahoo dot de
` (4 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: jwakely dot gcc at gmail dot com @ 2009-07-21 17:46 UTC (permalink / raw)
To: gcc-bugs
------- Comment #3 from jwakely dot gcc at gmail dot com 2009-07-21 17:45 -------
It tells you the location of the call. If you've specified the template
arguments at that location then you can see what they are, I don't see how
putting them in the diagnostic will save hours if you could find out the same
info in seconds by looking at the line.
There's no candidate list because there is no match for the template arguments
you used. The empty candidate list tells you something by itself.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40793
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/40793] "Error: no matching function for call to XYZ" doesn't display function-template-arguments
2009-07-17 22:09 [Bug c++/40793] New: "Error: no matching function for call to XYZ" doesn't display function-template-arguments jonathan dot sd24 at yahoo dot de
` (2 preceding siblings ...)
2009-07-21 17:46 ` jwakely dot gcc at gmail dot com
@ 2009-07-29 21:05 ` jonathan dot sd24 at yahoo dot de
2009-08-25 14:25 ` bangerth at gmail dot com
` (3 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: jonathan dot sd24 at yahoo dot de @ 2009-07-29 21:05 UTC (permalink / raw)
To: gcc-bugs
------- Comment #4 from jonathan dot sd24 at yahoo dot de 2009-07-29 21:05 -------
Template-Parameters can be results of long calculations or typedefs with
several layers of indirection.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40793
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/40793] "Error: no matching function for call to XYZ" doesn't display function-template-arguments
2009-07-17 22:09 [Bug c++/40793] New: "Error: no matching function for call to XYZ" doesn't display function-template-arguments jonathan dot sd24 at yahoo dot de
` (3 preceding siblings ...)
2009-07-29 21:05 ` jonathan dot sd24 at yahoo dot de
@ 2009-08-25 14:25 ` bangerth at gmail dot com
2010-07-01 8:58 ` m-matti-a dot lehtonen at iki dot fi
` (2 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: bangerth at gmail dot com @ 2009-08-25 14:25 UTC (permalink / raw)
To: gcc-bugs
------- Comment #5 from bangerth at gmail dot com 2009-08-25 14:25 -------
Jonathan, the point everyone is trying to make is this: since no function
or function template matches the call, all the compiler could possibly
do is list all declarations of the name staticPrint() or none, but of
course either choice is equally good.
But I think I understand what he means. In this example
----------------------
template<typename T, T t>
void staticPrint();
void f() {
staticPrint<double, "text">();
}
----------------------
He would like the error message to
say
no matching function for call to
'staticPrint<double,(const char[5])"text")>()'
instead of
no matching function for call to 'staticPrint()'
The reason being that it can indeed sometimes be hard to figure out what
template type the compiler is trying to match if they result from some
template trickery rather than being explicitly specified as done in the
example above.
I agree with this.
W.
--
bangerth at gmail dot com changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |bangerth at gmail dot com
Status|UNCONFIRMED |NEW
Ever Confirmed|0 |1
Keywords| |diagnostic
Last reconfirmed|0000-00-00 00:00:00 |2009-08-25 14:25:09
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40793
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/40793] "Error: no matching function for call to XYZ" doesn't display function-template-arguments
2009-07-17 22:09 [Bug c++/40793] New: "Error: no matching function for call to XYZ" doesn't display function-template-arguments jonathan dot sd24 at yahoo dot de
` (4 preceding siblings ...)
2009-08-25 14:25 ` bangerth at gmail dot com
@ 2010-07-01 8:58 ` m-matti-a dot lehtonen at iki dot fi
2010-07-01 21:31 ` manu at gcc dot gnu dot org
2010-07-01 21:38 ` bangerth at gmail dot com
7 siblings, 0 replies; 9+ messages in thread
From: m-matti-a dot lehtonen at iki dot fi @ 2010-07-01 8:58 UTC (permalink / raw)
To: gcc-bugs
------- Comment #6 from m-matti-a dot lehtonen at iki dot fi 2010-07-01 08:58 -------
I have spend recently many, Many hours with heavily template based code (using
CGAL - http://www.cgal.org/) until I figured, why my code failed.
Telling input types and candidate list of all mismatched functions would be
more then helpful than current way of reporting error.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40793
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/40793] "Error: no matching function for call to XYZ" doesn't display function-template-arguments
2009-07-17 22:09 [Bug c++/40793] New: "Error: no matching function for call to XYZ" doesn't display function-template-arguments jonathan dot sd24 at yahoo dot de
` (5 preceding siblings ...)
2010-07-01 8:58 ` m-matti-a dot lehtonen at iki dot fi
@ 2010-07-01 21:31 ` manu at gcc dot gnu dot org
2010-07-01 21:38 ` bangerth at gmail dot com
7 siblings, 0 replies; 9+ messages in thread
From: manu at gcc dot gnu dot org @ 2010-07-01 21:31 UTC (permalink / raw)
To: gcc-bugs
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1643 bytes --]
------- Comment #7 from manu at gcc dot gnu dot org 2010-07-01 21:31 -------
With the patch below, we print this:
pr40793.C:5:31: error: no matching function for call to staticPrint<double,
"text">()
pr40793.C:2:18: note: candidate is: template<class T, T t> void staticPrint()
but I am not sure if it is possible to print the type of "text". Any ideas?
Index: call.c
===================================================================
--- call.c (revision 161658)
+++ call.c (working copy)
@@ -3247,12 +3247,19 @@ build_new_function_call (tree fn, VEC(tr
{
if (!any_viable_p && candidates && ! candidates->next
&& (TREE_CODE (candidates->fn) == FUNCTION_DECL))
return cp_build_function_call_vec (candidates->fn, args, complain);
if (TREE_CODE (fn) == TEMPLATE_ID_EXPR)
- fn = TREE_OPERAND (fn, 0);
- if (!any_viable_p)
+ {
+ if (!any_viable_p)
+ error ("no matching function for call to %<%E(%A)%>",
+ fn, build_tree_list_vec (*args));
+ else
+ error ("call of overloaded %<%E(%A)%> is ambiguous",
+ fn, build_tree_list_vec (*args));
+ }
+ else if (!any_viable_p)
error ("no matching function for call to %<%D(%A)%>",
DECL_NAME (OVL_CURRENT (fn)), build_tree_list_vec (*args));
else
error ("call of overloaded %<%D(%A)%> is ambiguous",
DECL_NAME (OVL_CURRENT (fn)), build_tree_list_vec (*args));
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40793
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/40793] "Error: no matching function for call to XYZ" doesn't display function-template-arguments
2009-07-17 22:09 [Bug c++/40793] New: "Error: no matching function for call to XYZ" doesn't display function-template-arguments jonathan dot sd24 at yahoo dot de
` (6 preceding siblings ...)
2010-07-01 21:31 ` manu at gcc dot gnu dot org
@ 2010-07-01 21:38 ` bangerth at gmail dot com
7 siblings, 0 replies; 9+ messages in thread
From: bangerth at gmail dot com @ 2010-07-01 21:38 UTC (permalink / raw)
To: gcc-bugs
------- Comment #8 from bangerth at gmail dot com 2010-07-01 21:38 -------
I think that would already be an improvement.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40793
^ permalink raw reply [flat|nested] 9+ messages in thread