public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/56084] New: poor error recovery for missing ";"
@ 2013-01-23 15:44 manu at gcc dot gnu.org
  2013-01-23 15:44 ` [Bug c++/56084] " manu at gcc dot gnu.org
                   ` (10 more replies)
  0 siblings, 11 replies; 12+ messages in thread
From: manu at gcc dot gnu.org @ 2013-01-23 15:44 UTC (permalink / raw)
  To: gcc-bugs


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

             Bug #: 56084
           Summary: poor error recovery for missing ";"
    Classification: Unclassified
           Product: gcc
           Version: 4.8.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: manu@gcc.gnu.org


#include <string>
#include <iostream>

struct Student {
std::string surname;
std::string givenname;
}

std::ostream& operator<<(std::ostream& out, Student const& s) {
  return out << "{" << s.surname << ", " << s.givenname << "}";
}

int main() {
  Student me = { "Doe", "John" };
  std::cout << me << "\n";
}

clang not perfect but bearable:

test.cc:9:8: error: redefinition of 'ostream' as different kind of symbol
  std::ostream& operator<<(std::ostream& out, Student const& s) {
       ^
/usr/lib/gcc/x86_64-linux-gnu/4.4/../../../../include/c++/4.4/iosfwd:129:33:
note: previous definition is here
  typedef basic_ostream<char>           ostream;        ///< @isiosfwd
                                        ^
test.cc:9:15: error: expected ';' after top level declarator
  std::ostream& operator<<(std::ostream& out, Student const& s) {
              ^
              ;
2 errors generated.

G++ 4.8.0 awful:

test.cc:9:15: error: expected initializer before ‘&’ token
   std::ostream& operator<<(std::ostream& out, Student const& s) {
               ^
test.cc: In function ‘int main()’:
test.cc:15:13: error: no match for ‘operator<<’ (operand types are
‘std::ostream {aka std::basic_ostream<char>}’ and ‘Student’)
   std::cout << me << "\n";
             ^
test.cc:15:13: note: candidates are:
In file included from
/home/manuel/test1/195333M/install/include/c++/4.8.0/iostream:40:0,
                 from test.cc:2:
/home/manuel/test1/195333M/install/include/c++/4.8.0/ostream:110:7: note:
std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT,
_Traits>::operator<<(std::basic_ostream<_CharT, _Traits>::__ostream_type&
(*)(std::basic_ostream<_CharT, _Traits>::__ostream_type&)) [with _CharT = char;
_Traits = std::char_traits<char>; std::basic_ostream<_CharT,
_Traits>::__ostream_type = std::basic_ostream<char>]
       operator<<(__ostream_type& (*__pf)(__ostream_type&))
       ^
/home/manuel/test1/195333M/install/include/c++/4.8.0/ostream:110:7: note:   no
known conversion for argument 1 from ‘Student’ to
‘std::basic_ostream<char>::__ostream_type&
(*)(std::basic_ostream<char>::__ostream_type&) {aka std::basic_ostream<char>&
(*)(std::basic_ostream<char>&)}’
/home/manuel/test1/195333M/install/include/c++/4.8.0/ostream:119:7: note:
std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT,
_Traits>::operator<<(std::basic_ostream<_CharT, _Traits>::__ios_type&
(*)(std::basic_ostream<_CharT, _Traits>::__ios_type&)) [with _CharT = char;
_Traits = std::char_traits<char>; std::basic_ostream<_CharT,
_Traits>::__ostream_type = std::basic_ostream<char>; std::basic_ostream<_CharT,
_Traits>::__ios_type = std::basic_ios<char>]
       operator<<(__ios_type& (*__pf)(__ios_type&))
       ^
/home/manuel/test1/195333M/install/include/c++/4.8.0/ostream:119:7: note:   no
known conversion for argument 1 from ‘Student’ to
‘std::basic_ostream<char>::__ios_type&
(*)(std::basic_ostream<char>::__ios_type&) {aka std::basic_ios<char>&
(*)(std::basic_ios<char>&)}’
/home/manuel/test1/195333M/install/include/c++/4.8.0/ostream:129:7: note:
std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT,
_Traits>::operator<<(std::ios_base& (*)(std::ios_base&)) [with _CharT = char;
_Traits = std::char_traits<char>; std::basic_ostream<_CharT,
_Traits>::__ostream_type = std::basic_ostream<char>]
       operator<<(ios_base& (*__pf) (ios_base&))
       ^
/home/manuel/test1/195333M/install/include/c++/4.8.0/ostream:129:7: note:   no
known conversion for argument 1 from ‘Student’ to ‘std::ios_base&
(*)(std::ios_base&)’
/home/manuel/test1/195333M/install/include/c++/4.8.0/ostream:168:7: note:
std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT,
_Traits>::operator<<(long int) [with _CharT = char; _Traits =
std::char_traits<char>; std::basic_ostream<_CharT, _Traits>::__ostream_type =
std::basic_ostream<char>]
       operator<<(long __n)
       ^
/home/manuel/test1/195333M/install/include/c++/4.8.0/ostream:168:7: note:   no
known conversion for argument 1 from ‘Student’ to ‘long int’
/home/manuel/test1/195333M/install/include/c++/4.8.0/ostream:172:7: note:
std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT,
_Traits>::operator<<(long unsigned int) [with _CharT = char; _Traits =
std::char_traits<char>; std::basic_ostream<_CharT, _Traits>::__ostream_type =
std::basic_ostream<char>]
       operator<<(unsigned long __n)
       ^
/home/manuel/test1/195333M/install/include/c++/4.8.0/ostream:172:7: note:   no
known conversion for argument 1 from ‘Student’ to ‘long unsigned int’
/home/manuel/test1/195333M/install/include/c++/4.8.0/ostream:176:7: note:
std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT,
_Traits>::operator<<(bool) [with _CharT = char; _Traits =
std::char_traits<char>; std::basic_ostream<_CharT, _Traits>::__ostream_type =
std::basic_ostream<char>]
       operator<<(bool __n)
       ^
/home/manuel/test1/195333M/install/include/c++/4.8.0/ostream:176:7: note:   no
known conversion for argument 1 from ‘Student’ to ‘bool’
In file included from
/home/manuel/test1/195333M/install/include/c++/4.8.0/ostream:611:0,
                 from
/home/manuel/test1/195333M/install/include/c++/4.8.0/iostream:40,
                 from test.cc:2:
/home/manuel/test1/195333M/install/include/c++/4.8.0/bits/ostream.tcc:93:5:
note: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT,
_Traits>::operator<<(short int) [with _CharT = char; _Traits =
std::char_traits<char>]
     basic_ostream<_CharT, _Traits>::
     ^
/home/manuel/test1/195333M/install/include/c++/4.8.0/bits/ostream.tcc:93:5:
note:   no known conversion for argument 1 from ‘Student’ to ‘short int’
In file included from
/home/manuel/test1/195333M/install/include/c++/4.8.0/iostream:40:0,
                 from test.cc:2:
/home/manuel/test1/195333M/install/include/c++/4.8.0/ostream:183:7: note:
std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT,
_Traits>::operator<<(short unsigned int) [with _CharT = char; _Traits =
std::char_traits<char>; std::basic_ostream<_CharT, _Traits>::__ostream_type =
std::basic_ostream<char>]
       operator<<(unsigned short __n)
       ^
/home/manuel/test1/195333M/install/include/c++/4.8.0/ostream:183:7: note:   no
known conversion for argument 1 from ‘Student’ to ‘short unsigned int’
In file included from
/home/manuel/test1/195333M/install/include/c++/4.8.0/ostream:611:0,
                 from
/home/manuel/test1/195333M/install/include/c++/4.8.0/iostream:40,
                 from test.cc:2:
/home/manuel/test1/195333M/install/include/c++/4.8.0/bits/ostream.tcc:107:5:
note: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT,
_Traits>::operator<<(int) [with _CharT = char; _Traits =
std::char_traits<char>]
     basic_ostream<_CharT, _Traits>::
     ^
/home/manuel/test1/195333M/install/include/c++/4.8.0/bits/ostream.tcc:107:5:
note:   no known conversion for argument 1 from ‘Student’ to ‘int’
In file included from
/home/manuel/test1/195333M/install/include/c++/4.8.0/iostream:40:0,
                 from test.cc:2:
/home/manuel/test1/195333M/install/include/c++/4.8.0/ostream:194:7: note:
std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT,
_Traits>::operator<<(unsigned int) [with _CharT = char; _Traits =
std::char_traits<char>; std::basic_ostream<_CharT, _Traits>::__ostream_type =
std::basic_ostream<char>]
       operator<<(unsigned int __n)
       ^
/home/manuel/test1/195333M/install/include/c++/4.8.0/ostream:194:7: note:   no
known conversion for argument 1 from ‘Student’ to ‘unsigned int’
/home/manuel/test1/195333M/install/include/c++/4.8.0/ostream:203:7: note:
std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT,
_Traits>::operator<<(long long int) [with _CharT = char; _Traits =
std::char_traits<char>; std::basic_ostream<_CharT, _Traits>::__ostream_type =
std::basic_ostream<char>]
       operator<<(long long __n)
       ^
/home/manuel/test1/195333M/install/include/c++/4.8.0/ostream:203:7: note:   no
known conversion for argument 1 from ‘Student’ to ‘long long int’
/home/manuel/test1/195333M/install/include/c++/4.8.0/ostream:207:7: note:
std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT,
_Traits>::operator<<(long long unsigned int) [with _CharT = char; _Traits =
std::char_traits<char>; std::basic_ostream<_CharT, _Traits>::__ostream_type =
std::basic_ostream<char>]
       operator<<(unsigned long long __n)
       ^
/home/manuel/test1/195333M/install/include/c++/4.8.0/ostream:207:7: note:   no
known conversion for argument 1 from ‘Student’ to ‘long long unsigned int’
/home/manuel/test1/195333M/install/include/c++/4.8.0/ostream:222:7: note:
std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT,
_Traits>::operator<<(double) [with _CharT = char; _Traits =
std::char_traits<char>; std::basic_ostream<_CharT, _Traits>::__ostream_type =
std::basic_ostream<char>]
       operator<<(double __f)
       ^
/home/manuel/test1/195333M/install/include/c++/4.8.0/ostream:222:7: note:   no
known conversion for argument 1 from ‘Student’ to ‘double’
/home/manuel/test1/195333M/install/include/c++/4.8.0/ostream:226:7: note:
std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT,
_Traits>::operator<<(float) [with _CharT = char; _Traits =
std::char_traits<char>; std::basic_ostream<_CharT, _Traits>::__ostream_type =
std::basic_ostream<char>]
       operator<<(float __f)
       ^
/home/manuel/test1/195333M/install/include/c++/4.8.0/ostream:226:7: note:   no
known conversion for argument 1 from ‘Student’ to ‘float’
/home/manuel/test1/195333M/install/include/c++/4.8.0/ostream:234:7: note:
std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT,
_Traits>::operator<<(long double) [with _CharT = char; _Traits =
std::char_traits<char>; std::basic_ostream<_CharT, _Traits>::__ostream_type =
std::basic_ostream<char>]
       operator<<(long double __f)
       ^
/home/manuel/test1/195333M/install/include/c++/4.8.0/ostream:234:7: note:   no
known conversion for argument 1 from ‘Student’ to ‘long double’
/home/manuel/test1/195333M/install/include/c++/4.8.0/ostream:247:7: note:
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)
       ^
/home/manuel/test1/195333M/install/include/c++/4.8.0/ostream:247:7: note:   no
known conversion for argument 1 from ‘Student’ to ‘const void*’
In file included from
/home/manuel/test1/195333M/install/include/c++/4.8.0/ostream:611:0,
                 from
/home/manuel/test1/195333M/install/include/c++/4.8.0/iostream:40,
                 from test.cc:2:
/home/manuel/test1/195333M/install/include/c++/4.8.0/bits/ostream.tcc:121:5:
note: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT,
_Traits>::operator<<(std::basic_ostream<_CharT, _Traits>::__streambuf_type*)
[with _CharT = char; _Traits = std::char_traits<char>;
std::basic_ostream<_CharT, _Traits>::__streambuf_type =
std::basic_streambuf<char>]
     basic_ostream<_CharT, _Traits>::
     ^
/home/manuel/test1/195333M/install/include/c++/4.8.0/bits/ostream.tcc:121:5:
note:   no known conversion for argument 1 from ‘Student’ to
‘std::basic_ostream<char>::__streambuf_type* {aka std::basic_streambuf<char>*}’
In file included from
/home/manuel/test1/195333M/install/include/c++/4.8.0/iostream:40:0,
                 from test.cc:2:
/home/manuel/test1/195333M/install/include/c++/4.8.0/ostream:550:5: note:
template<class _Traits> std::basic_ostream<char, _Traits>&
std::operator<<(std::basic_ostream<char, _Traits>&, const unsigned char*)
     operator<<(basic_ostream<char, _Traits>& __out, const unsigned char* __s)
     ^
/home/manuel/test1/195333M/install/include/c++/4.8.0/ostream:550:5: note:  
template argument deduction/substitution failed:
test.cc:15:16: note:   cannot convert ‘me’ (type ‘Student’) to type ‘const
unsigned char*’
   std::cout << me << "\n";
                ^
In file included from
/home/manuel/test1/195333M/install/include/c++/4.8.0/iostream:40:0,
                 from test.cc:2:
/home/manuel/test1/195333M/install/include/c++/4.8.0/ostream:545: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)
     ^
/home/manuel/test1/195333M/install/include/c++/4.8.0/ostream:545:5: note:  
template argument deduction/substitution failed:
test.cc:15:16: note:   cannot convert ‘me’ (type ‘Student’) to type ‘const
signed char*’
   std::cout << me << "\n";
                ^
In file included from
/home/manuel/test1/195333M/install/include/c++/4.8.0/iostream:40:0,
                 from test.cc:2:
/home/manuel/test1/195333M/install/include/c++/4.8.0/ostream:532:5: note:
template<class _Traits> std::basic_ostream<char, _Traits>&
std::operator<<(std::basic_ostream<char, _Traits>&, const char*)
     operator<<(basic_ostream<char, _Traits>& __out, const char* __s)
     ^
/home/manuel/test1/195333M/install/include/c++/4.8.0/ostream:532:5: note:  
template argument deduction/substitution failed:
test.cc:15:16: note:   cannot convert ‘me’ (type ‘Student’) to type ‘const
char*’
   std::cout << me << "\n";
                ^
In file included from
/home/manuel/test1/195333M/install/include/c++/4.8.0/ostream:611:0,
                 from
/home/manuel/test1/195333M/install/include/c++/4.8.0/iostream:40,
                 from test.cc:2:
/home/manuel/test1/195333M/install/include/c++/4.8.0/bits/ostream.tcc:323:5:
note: template<class _CharT, class _Traits> std::basic_ostream<_CharT,
_Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&, const char*)
     operator<<(basic_ostream<_CharT, _Traits>& __out, const char* __s)
     ^
/home/manuel/test1/195333M/install/include/c++/4.8.0/bits/ostream.tcc:323:5:
note:   template argument deduction/substitution failed:
test.cc:15:16: note:   cannot convert ‘me’ (type ‘Student’) to type ‘const
char*’
   std::cout << me << "\n";
                ^
In file included from
/home/manuel/test1/195333M/install/include/c++/4.8.0/iostream:40:0,
                 from test.cc:2:
/home/manuel/test1/195333M/install/include/c++/4.8.0/ostream:515:5: note:
template<class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>&
std::operator<<(std::basic_ostream<_CharT, _Traits>&, const _CharT*)
     operator<<(basic_ostream<_CharT, _Traits>& __out, const _CharT* __s)
     ^
/home/manuel/test1/195333M/install/include/c++/4.8.0/ostream:515:5: note:  
template argument deduction/substitution failed:
test.cc:15:16: note:   mismatched types ‘const _CharT*’ and ‘Student’
   std::cout << me << "\n";
                ^
In file included from
/home/manuel/test1/195333M/install/include/c++/4.8.0/iostream:40:0,
                 from test.cc:2:
/home/manuel/test1/195333M/install/include/c++/4.8.0/ostream:495:5: note:
template<class _Traits> std::basic_ostream<char, _Traits>&
std::operator<<(std::basic_ostream<char, _Traits>&, unsigned char)
     operator<<(basic_ostream<char, _Traits>& __out, unsigned char __c)
     ^
/home/manuel/test1/195333M/install/include/c++/4.8.0/ostream:495:5: note:  
template argument deduction/substitution failed:
test.cc:15:16: note:   cannot convert ‘me’ (type ‘Student’) to type ‘unsigned
char’
   std::cout << me << "\n";
                ^
In file included from
/home/manuel/test1/195333M/install/include/c++/4.8.0/iostream:40:0,
                 from test.cc:2:
/home/manuel/test1/195333M/install/include/c++/4.8.0/ostream:490:5: note:
template<class _Traits> std::basic_ostream<char, _Traits>&
std::operator<<(std::basic_ostream<char, _Traits>&, signed char)
     operator<<(basic_ostream<char, _Traits>& __out, signed char __c)
     ^
/home/manuel/test1/195333M/install/include/c++/4.8.0/ostream:490:5: note:  
template argument deduction/substitution failed:
test.cc:15:16: note:   cannot convert ‘me’ (type ‘Student’) to type ‘signed
char’
   std::cout << me << "\n";
                ^
In file included from
/home/manuel/test1/195333M/install/include/c++/4.8.0/iostream:40:0,
                 from test.cc:2:
/home/manuel/test1/195333M/install/include/c++/4.8.0/ostream:484:5: note:
template<class _Traits> std::basic_ostream<char, _Traits>&
std::operator<<(std::basic_ostream<char, _Traits>&, char)
     operator<<(basic_ostream<char, _Traits>& __out, char __c)
     ^
/home/manuel/test1/195333M/install/include/c++/4.8.0/ostream:484:5: note:  
template argument deduction/substitution failed:
test.cc:15:16: note:   cannot convert ‘me’ (type ‘Student’) to type ‘char’
   std::cout << me << "\n";
                ^
In file included from
/home/manuel/test1/195333M/install/include/c++/4.8.0/iostream:40:0,
                 from test.cc:2:
/home/manuel/test1/195333M/install/include/c++/4.8.0/ostream:478:5: note:
template<class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>&
std::operator<<(std::basic_ostream<_CharT, _Traits>&, char)
     operator<<(basic_ostream<_CharT, _Traits>& __out, char __c)
     ^
/home/manuel/test1/195333M/install/include/c++/4.8.0/ostream:478:5: note:  
template argument deduction/substitution failed:
test.cc:15:16: note:   cannot convert ‘me’ (type ‘Student’) to type ‘char’
   std::cout << me << "\n";
                ^
In file included from
/home/manuel/test1/195333M/install/include/c++/4.8.0/iostream:40:0,
                 from test.cc:2:
/home/manuel/test1/195333M/install/include/c++/4.8.0/ostream:473:5: note:
template<class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>&
std::operator<<(std::basic_ostream<_CharT, _Traits>&, _CharT)
     operator<<(basic_ostream<_CharT, _Traits>& __out, _CharT __c)
     ^
/home/manuel/test1/195333M/install/include/c++/4.8.0/ostream:473:5: note:  
template argument deduction/substitution failed:
test.cc:15:16: note:   deduced conflicting types for parameter ‘_CharT’ (‘char’
and ‘Student’)
   std::cout << me << "\n";
                ^
In file included from
/home/manuel/test1/195333M/install/include/c++/4.8.0/string:54:0,
                 from test.cc:1:
/home/manuel/test1/195333M/install/include/c++/4.8.0/bits/basic_string.h:2755:5:
note: template<class _CharT, class _Traits, class _Alloc>
std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT,
_Traits>&, const std::basic_string<_CharT, _Traits, _Alloc>&)
     operator<<(basic_ostream<_CharT, _Traits>& __os,
     ^
/home/manuel/test1/195333M/install/include/c++/4.8.0/bits/basic_string.h:2755:5:
note:   template argument deduction/substitution failed:
test.cc:15:16: note:   ‘Student’ is not derived from ‘const
std::basic_string<_CharT, _Traits, _Alloc>’
   std::cout << me << "\n";
                ^


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug c++/56084] poor error recovery for missing ";"
  2013-01-23 15:44 [Bug c++/56084] New: poor error recovery for missing ";" manu at gcc dot gnu.org
@ 2013-01-23 15:44 ` manu at gcc dot gnu.org
  2013-01-23 16:25 ` redi at gcc dot gnu.org
                   ` (9 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: manu at gcc dot gnu.org @ 2013-01-23 15:44 UTC (permalink / raw)
  To: gcc-bugs


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

Manuel López-Ibáñez <manu at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |diagnostic

--- Comment #1 from Manuel López-Ibáñez <manu at gcc dot gnu.org> 2013-01-23 15:44:21 UTC ---
Originally from:
http://stackoverflow.com/questions/8205858/clang-vs-gcc-for-linux-development-compare-and-contrast


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug c++/56084] poor error recovery for missing ";"
  2013-01-23 15:44 [Bug c++/56084] New: poor error recovery for missing ";" manu at gcc dot gnu.org
  2013-01-23 15:44 ` [Bug c++/56084] " manu at gcc dot gnu.org
@ 2013-01-23 16:25 ` redi at gcc dot gnu.org
  2013-01-23 17:02 ` manu at gcc dot gnu.org
                   ` (8 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: redi at gcc dot gnu.org @ 2013-01-23 16:25 UTC (permalink / raw)
  To: gcc-bugs


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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2013-01-23
     Ever Confirmed|0                           |1

--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> 2013-01-23 16:25:18 UTC ---
This reduces to:

struct ostream { };

struct A {
    int i;
}

ostream& operator<<(ostream& o, const A&) { return o; }

int main()
{
    A a;
    ostream o;
    o << a;
}

which still gives a poor error that doesn't identify the problem, but it
doesn't give pages of errors because there is only one operator<< in scope

x.cc:7:8: error: expected initializer before '&' token
 ostream& operator<<(ostream& o, const A&) { return o; }
        ^
x.cc: In function 'int main()':
x.cc:13:7: error: no match for 'operator<<' (operand types are 'ostream' and
'A')
     o << a;
       ^

(Separately, I'm investigating whether there's some way to reduce the output
when an invalid ostream operation is done, because the sheer number of
overloads of operator<< causes pages of output due to G++'s verbose, and
usually very useful, output describing argument deduction errors.)


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug c++/56084] poor error recovery for missing ";"
  2013-01-23 15:44 [Bug c++/56084] New: poor error recovery for missing ";" manu at gcc dot gnu.org
  2013-01-23 15:44 ` [Bug c++/56084] " manu at gcc dot gnu.org
  2013-01-23 16:25 ` redi at gcc dot gnu.org
@ 2013-01-23 17:02 ` manu at gcc dot gnu.org
  2013-01-23 17:05 ` manu at gcc dot gnu.org
                   ` (7 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: manu at gcc dot gnu.org @ 2013-01-23 17:02 UTC (permalink / raw)
  To: gcc-bugs


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

--- Comment #3 from Manuel López-Ibáñez <manu at gcc dot gnu.org> 2013-01-23 17:02:02 UTC ---
> (Separately, I'm investigating whether there's some way to reduce the output
> when an invalid ostream operation is done, because the sheer number of
> overloads of operator<< causes pages of output due to G++'s verbose, and
> usually very useful, output describing argument deduction errors.)

One clear way is to avoid the repetition of:

In file included from
/home/manuel/test1/195333M/install/include/c++/4.8.0/iostream:40:0,
                 from test.cc:2:

Another is to add a "foverload-candidates-limit" option like
ftemplate-backtrace-limit, so if there are more than the limit (let's say 5),
the output is elided in a similar fashion.

Another suggestion is to don't show the full function declaration like in:

In file included from
/home/manuel/test1/195333M/install/include/c++/4.8.0/iostream:40:0,
                 from test.cc:2:
/home/manuel/test1/195333M/install/include/c++/4.8.0/ostream:532:5: note:
template<class _Traits> std::basic_ostream<char, _Traits>&
std::operator<<(std::basic_ostream<char, _Traits>&, const char*)
     operator<<(basic_ostream<char, _Traits>& __out, const char* __s)
     ^
/home/manuel/test1/195333M/install/include/c++/4.8.0/ostream:532:5: note:  
template argument deduction/substitution failed:
test.cc:16:16: note:   cannot convert ‘me’ (type ‘Student’) to type ‘const
char*’
   std::cout << me << "\n";
                ^

where clang says in 1 line:

/usr/lib/gcc/x86_64-linux-gnu/4.4/../../../../include/c++/4.4/bits/ostream.tcc:320:5:
note: candidate function [with _CharT = char, _Traits = std::char_traits<char>]
not viable: no known conversion from 'Student' to 'const char *' for 2nd
argument
    operator<<(basic_ostream<_CharT, _Traits>& __out, const char* __s)


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug c++/56084] poor error recovery for missing ";"
  2013-01-23 15:44 [Bug c++/56084] New: poor error recovery for missing ";" manu at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2013-01-23 17:02 ` manu at gcc dot gnu.org
@ 2013-01-23 17:05 ` manu at gcc dot gnu.org
  2013-01-23 17:11 ` manu at gcc dot gnu.org
                   ` (6 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: manu at gcc dot gnu.org @ 2013-01-23 17:05 UTC (permalink / raw)
  To: gcc-bugs


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

--- Comment #4 from Manuel López-Ibáñez <manu at gcc dot gnu.org> 2013-01-23 17:05:14 UTC ---
BTW, what is the difference between deduction and substitution?


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug c++/56084] poor error recovery for missing ";"
  2013-01-23 15:44 [Bug c++/56084] New: poor error recovery for missing ";" manu at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2013-01-23 17:05 ` manu at gcc dot gnu.org
@ 2013-01-23 17:11 ` manu at gcc dot gnu.org
  2013-01-23 17:18 ` glisse at gcc dot gnu.org
                   ` (5 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: manu at gcc dot gnu.org @ 2013-01-23 17:11 UTC (permalink / raw)
  To: gcc-bugs


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

--- Comment #5 from Manuel López-Ibáñez <manu at gcc dot gnu.org> 2013-01-23 17:10:58 UTC ---
Of course, the color output makes much easier to spot the "note:". And the use
of a common prefix "note: candidate function..." or "note: candidate
template..." also makes easier to spot the start of each individual
explanation.


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug c++/56084] poor error recovery for missing ";"
  2013-01-23 15:44 [Bug c++/56084] New: poor error recovery for missing ";" manu at gcc dot gnu.org
                   ` (4 preceding siblings ...)
  2013-01-23 17:11 ` manu at gcc dot gnu.org
@ 2013-01-23 17:18 ` glisse at gcc dot gnu.org
  2013-01-23 17:31 ` manu at gcc dot gnu.org
                   ` (4 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: glisse at gcc dot gnu.org @ 2013-01-23 17:18 UTC (permalink / raw)
  To: gcc-bugs


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

--- Comment #6 from Marc Glisse <glisse at gcc dot gnu.org> 2013-01-23 17:17:53 UTC ---
(In reply to comment #5)
> Of course, the color output makes much easier to spot the "note:".

Er, not here, bold black (the color they chose for "note:") on a black
background is pretty hard to read...
(otherwise I agree that colors help)


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug c++/56084] poor error recovery for missing ";"
  2013-01-23 15:44 [Bug c++/56084] New: poor error recovery for missing ";" manu at gcc dot gnu.org
                   ` (5 preceding siblings ...)
  2013-01-23 17:18 ` glisse at gcc dot gnu.org
@ 2013-01-23 17:31 ` manu at gcc dot gnu.org
  2013-01-23 17:44 ` redi at gcc dot gnu.org
                   ` (3 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: manu at gcc dot gnu.org @ 2013-01-23 17:31 UTC (permalink / raw)
  To: gcc-bugs


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

--- Comment #7 from Manuel López-Ibáñez <manu at gcc dot gnu.org> 2013-01-23 17:31:21 UTC ---
Strange. In the GCC farm and without any customization, clang uses gray for the
note. I have seen presentations where it also uses this color scheme. I don't
know if they have some brackground-color detection, and it fails in your case.


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug c++/56084] poor error recovery for missing ";"
  2013-01-23 15:44 [Bug c++/56084] New: poor error recovery for missing ";" manu at gcc dot gnu.org
                   ` (6 preceding siblings ...)
  2013-01-23 17:31 ` manu at gcc dot gnu.org
@ 2013-01-23 17:44 ` redi at gcc dot gnu.org
  2020-03-12 11:58 ` jakub at gcc dot gnu.org
                   ` (2 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: redi at gcc dot gnu.org @ 2013-01-23 17:44 UTC (permalink / raw)
  To: gcc-bugs


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

--- Comment #8 from Jonathan Wakely <redi at gcc dot gnu.org> 2013-01-23 17:44:24 UTC ---
(In reply to comment #4)
> BTW, what is the difference between deduction and substitution?

Some template arguments are deduced from the function arguments, and those
arguments are then substituted into the rest of the function template signature
to form a function signature.

e.g.

template<typename T, typename U=T>
void func(T, typename T::iterator)
{ }

If you call 'func(v, v.begin())' then T will be deduced from the type of 'v', U
will be deduced as the same type, then that type will be substituted into the
type T::iterator. If 'v' has no nested 'iterator' type then substitution fails
and so deduction fails, and the template cannot be called.


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug c++/56084] poor error recovery for missing ";"
  2013-01-23 15:44 [Bug c++/56084] New: poor error recovery for missing ";" manu at gcc dot gnu.org
                   ` (7 preceding siblings ...)
  2013-01-23 17:44 ` redi at gcc dot gnu.org
@ 2020-03-12 11:58 ` jakub at gcc dot gnu.org
  2021-06-01  8:05 ` rguenth at gcc dot gnu.org
  2021-06-01  9:23 ` redi at gcc dot gnu.org
  10 siblings, 0 replies; 12+ messages in thread
From: jakub at gcc dot gnu.org @ 2020-03-12 11:58 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56084

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|9.3                         |9.4

--- Comment #12 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
GCC 9.3.0 has been released, adjusting target milestone.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug c++/56084] poor error recovery for missing ";"
  2013-01-23 15:44 [Bug c++/56084] New: poor error recovery for missing ";" manu at gcc dot gnu.org
                   ` (8 preceding siblings ...)
  2020-03-12 11:58 ` jakub at gcc dot gnu.org
@ 2021-06-01  8:05 ` rguenth at gcc dot gnu.org
  2021-06-01  9:23 ` redi at gcc dot gnu.org
  10 siblings, 0 replies; 12+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-06-01  8:05 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56084

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|9.4                         |9.5

--- Comment #13 from Richard Biener <rguenth at gcc dot gnu.org> ---
GCC 9.4 is being released, retargeting bugs to GCC 9.5.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug c++/56084] poor error recovery for missing ";"
  2013-01-23 15:44 [Bug c++/56084] New: poor error recovery for missing ";" manu at gcc dot gnu.org
                   ` (9 preceding siblings ...)
  2021-06-01  8:05 ` rguenth at gcc dot gnu.org
@ 2021-06-01  9:23 ` redi at gcc dot gnu.org
  10 siblings, 0 replies; 12+ messages in thread
From: redi at gcc dot gnu.org @ 2021-06-01  9:23 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56084

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|9.5                         |---

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2021-06-01  9:23 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-01-23 15:44 [Bug c++/56084] New: poor error recovery for missing ";" manu at gcc dot gnu.org
2013-01-23 15:44 ` [Bug c++/56084] " manu at gcc dot gnu.org
2013-01-23 16:25 ` redi at gcc dot gnu.org
2013-01-23 17:02 ` manu at gcc dot gnu.org
2013-01-23 17:05 ` manu at gcc dot gnu.org
2013-01-23 17:11 ` manu at gcc dot gnu.org
2013-01-23 17:18 ` glisse at gcc dot gnu.org
2013-01-23 17:31 ` manu at gcc dot gnu.org
2013-01-23 17:44 ` redi at gcc dot gnu.org
2020-03-12 11:58 ` jakub at gcc dot gnu.org
2021-06-01  8:05 ` rguenth at gcc dot gnu.org
2021-06-01  9:23 ` redi at gcc dot gnu.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).