This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/67499] c++ template/overload diagnostic compression
- From: "manu at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 09 Sep 2015 10:03:13 +0000
- Subject: [Bug c++/67499] c++ template/overload diagnostic compression
- Auto-submitted: auto-generated
- References: <bug-67499-4 at http dot gcc dot gnu dot org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67499
--- Comment #7 from Manuel LÃpez-IbÃÃez <manu at gcc dot gnu.org> ---
(In reply to Marc Glisse from comment #6)
> In the example above, you dropped the
> information that it is 'bar' (the second argument) that cannot be converted,
> which, for a function with more arguments and templates and typedefs all
> over the place, might not be obvious at all.
This info is already implied by the error:
test.cc:5:15: error: no match for âoperator<<â (operand types are âstd::ostream
{aka std::basic_ostream<char>}â and âfooâ)
std::cout << bar;
^
It is also inconsistently printed for some conversions:
/usr/include/c++/4.8/ostream:543:5: note: template<class _Traits>
std::basic_ostream<char, _Traits>& std::operator<<(std::basic_ostream<char,
_Traits>&, const signed char*)
operator<<(basic_ostream<char, _Traits>& __out, const signed char* __s)
^
/usr/include/c++/4.8/ostream:543:5: note: template argument
deduction/substitution failed:
test.cc:5:18: note: cannot convert âbarâ (type âfooâ) to type âconst signed
char*â
std::cout << bar;
^
but not for others:
/usr/include/c++/4.8/ostream:245:7: note: std::basic_ostream<_CharT,
_Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(const
void*) [with _CharT = char; _Trai
ts = std::char_traits<char>; std::basic_ostream<_CharT,
_Traits>::__ostream_type = std::basic_ostream<char>]
operator<<(const void* __p)
^
/usr/include/c++/4.8/ostream:245:7: note: no known conversion for argument 1
from âfooâ to âconst void*â
Note that I'm ok with printing:
/usr/include/c++/4.8/ostream:543:5: note: template argument
deduction/substitution failed: cannot convert âbarâ (type âfooâ) to type âconst
signed char*â
or even:
/usr/include/c++/4.8/ostream:543:5: note: template argument
deduction/substitution failed: cannot convert âbarâ (type âfooâ) to type âconst
signed char*â for argument 1
My point is to not print:
test.cc:5:18: note: X
std::cout << bar;
^
for the error AND for every candidate.
For example, we could print:
test.cc:5:15: error: no match for âoperator<<â (operand types are âstd::ostream
{aka std::basic_ostream<char>}â and âfooâ)
std::cout << bar;
^
test.cc:5:18: note: template argument deduction/substitution failed: cannot
convert âbarâ (type âfooâ)
std::cout << bar;
^
/usr/include/c++/4.8/ostream:245:7: note: candidate 1: no known conversion for
argument 1 from âfooâ to âconst void*â for 'std::basic_ostream<_CharT,
_Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(const
void*) [with _CharT = char; _Traits = std::char_traits<char>;
std::basic_ostream<_CharT, _Traits>::__ostream_type =
std::basic_ostream<char>]'
operator<<(const void* __p)
^
/usr/include/c++/4.8/ostream:543:5: note: candidate 2: cannot convert type
âfooâ to type âconst signed char*â for 'template<class _Traits>
std::basic_ostream<char, _Traits>& std::operator<<(std::basic_ostream<char,
_Traits>&, const signed char*)'
operator<<(basic_ostream<char, _Traits>& __out, const signed char* __s)
^
[etc.]
> If we were outputting html, it would be much easier, we could print the
> error message and have javascript so that clicking in appropriate places
> displays the candidates, the reason for substitution failure, what a type is
> an alias for, etc. This is something IDEs could do. But with text, we have
> to print everything that might be useful.
We could still print it in a smarter, nicer looking and consistent way, without
repeating the same info several times (in the example above, there are only 108
unique lines out of 193).