This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/51149] New: Smarter error output in a few template deduction/substitution failure cases
- From: "darlingmoff at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 16 Nov 2011 03:43:22 +0000
- Subject: [Bug c++/51149] New: Smarter error output in a few template deduction/substitution failure cases
- Auto-submitted: auto-generated
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51149
Bug #: 51149
Summary: Smarter error output in a few template
deduction/substitution failure cases
Classification: Unclassified
Product: gcc
Version: 4.7.0
Status: UNCONFIRMED
Severity: enhancement
Priority: P3
Component: c++
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: darlingmoff@gmail.com
I have a suggestion of making error output in two cases more helpful. I've got
to admit that I don't know if there's a good way to implement this.
It's really nice that g++ makes suggestions, for when you're a little bit off
the mark.
But, there's two situations I tend to do all the time that cause several pages
of irrelevant suggestions/template failures fly by. If you do several of these
at once, it takes a while to find the offending line numbers. I often scroll
to top of errors, fix that line, try recompiling. I'm not able to efficiently
pick out the line numbers all at once, since there's so much between the lines
I need to read.
I like the feature of g++ saying "maybe you meant ->" if you use "." on a
pointer. If there would be a way to implement something like that on these
cases, it would be nice.
Case - When working a lot with streams, forgetting you're momentarily working
with a string
[example]string theString = anotherString << "text"; // note it should be
"+"[/example]
In this case, g++ gives many, many lines showing template argument
deduction/substitution failed, where if a single line would do that states
"maybe you meant + instead of <<".
Case - When meaning to call a lambda function, forgetting parenthesis
[example]auto lambda = [] { return "text"; };
if("text" == lambda) cout << "It's text" << endl; // note it should be
"lambda()"[/example]
In this case, g++ gives many, many lines showing template argument
deduction/substitution failed, where if a single line would do that states
"maybe you forgot ()".
I do realize that the errors it gives are helpful in situations where someone
hasn't made one of these typos, so I realize that giving these shorter error
messages might be helpful to me, but less helpful to others. That's why I said
I'm not sure if there's a good way to implement this, but I hope there is.