From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4848 invoked by alias); 23 Jan 2013 15:44:07 -0000 Received: (qmail 4762 invoked by uid 48); 23 Jan 2013 15:43:48 -0000 From: "manu at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/56084] New: poor error recovery for missing ";" Date: Wed, 23 Jan 2013 15:44:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: manu at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Message-ID: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2013-01/txt/msg02175.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D56084 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 #include 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 =3D { "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 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 =E2=80=98&=E2=80=99 token std::ostream& operator<<(std::ostream& out, Student const& s) { ^ test.cc: In function =E2=80=98int main()=E2=80=99: test.cc:15:13: error: no match for =E2=80=98operator<<=E2=80=99 (operand ty= pes are =E2=80=98std::ostream {aka std::basic_ostream}=E2=80=99 and =E2=80=98= Student=E2=80=99) 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<_Ch= arT, _Traits>::operator<<(std::basic_ostream<_CharT, _Traits>::__ostream_type& (*)(std::basic_ostream<_CharT, _Traits>::__ostream_type&)) [with _CharT =3D= char; _Traits =3D std::char_traits; std::basic_ostream<_CharT, _Traits>::__ostream_type =3D std::basic_ostream] 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 =E2=80=98Student=E2=80=99 to =E2=80=98std::basic_ostream::__ostream_type& (*)(std::basic_ostream::__ostream_type&) {aka std::basic_ostream& (*)(std::basic_ostream&)}=E2=80=99 /home/manuel/test1/195333M/install/include/c++/4.8.0/ostream:119:7: note: std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_Ch= arT, _Traits>::operator<<(std::basic_ostream<_CharT, _Traits>::__ios_type& (*)(std::basic_ostream<_CharT, _Traits>::__ios_type&)) [with _CharT =3D cha= r; _Traits =3D std::char_traits; std::basic_ostream<_CharT, _Traits>::__ostream_type =3D std::basic_ostream; std::basic_ostream<_= CharT, _Traits>::__ios_type =3D std::basic_ios] 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 =E2=80=98Student=E2=80=99 to =E2=80=98std::basic_ostream::__ios_type& (*)(std::basic_ostream::__ios_type&) {aka std::basic_ios& (*)(std::basic_ios&)}=E2=80=99 /home/manuel/test1/195333M/install/include/c++/4.8.0/ostream:129:7: note: std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_Ch= arT, _Traits>::operator<<(std::ios_base& (*)(std::ios_base&)) [with _CharT =3D c= har; _Traits =3D std::char_traits; std::basic_ostream<_CharT, _Traits>::__ostream_type =3D std::basic_ostream] 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 =E2=80=98Student=E2=80=99 to =E2=80=98= std::ios_base& (*)(std::ios_base&)=E2=80=99 /home/manuel/test1/195333M/install/include/c++/4.8.0/ostream:168:7: note: std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_Ch= arT, _Traits>::operator<<(long int) [with _CharT =3D char; _Traits =3D std::char_traits; std::basic_ostream<_CharT, _Traits>::__ostream_type= =3D std::basic_ostream] operator<<(long __n) ^ /home/manuel/test1/195333M/install/include/c++/4.8.0/ostream:168:7: note: = no known conversion for argument 1 from =E2=80=98Student=E2=80=99 to =E2=80=98= long int=E2=80=99 /home/manuel/test1/195333M/install/include/c++/4.8.0/ostream:172:7: note: std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_Ch= arT, _Traits>::operator<<(long unsigned int) [with _CharT =3D char; _Traits =3D std::char_traits; std::basic_ostream<_CharT, _Traits>::__ostream_type= =3D std::basic_ostream] 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 =E2=80=98Student=E2=80=99 to =E2=80=98= long unsigned int=E2=80=99 /home/manuel/test1/195333M/install/include/c++/4.8.0/ostream:176:7: note: std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_Ch= arT, _Traits>::operator<<(bool) [with _CharT =3D char; _Traits =3D std::char_traits; std::basic_ostream<_CharT, _Traits>::__ostream_type= =3D std::basic_ostream] operator<<(bool __n) ^ /home/manuel/test1/195333M/install/include/c++/4.8.0/ostream:176:7: note: = no known conversion for argument 1 from =E2=80=98Student=E2=80=99 to =E2=80=98= bool=E2=80=99 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 =3D char; _Traits =3D std::char_traits] 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 =E2=80=98Student=E2=80=99 t= o =E2=80=98short int=E2=80=99 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<_Ch= arT, _Traits>::operator<<(short unsigned int) [with _CharT =3D char; _Traits =3D std::char_traits; std::basic_ostream<_CharT, _Traits>::__ostream_type= =3D std::basic_ostream] 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 =E2=80=98Student=E2=80=99 to =E2=80=98= short unsigned int=E2=80=99 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 =3D char; _Traits =3D std::char_traits] 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 =E2=80=98Student=E2=80=99 t= o =E2=80=98int=E2=80=99 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<_Ch= arT, _Traits>::operator<<(unsigned int) [with _CharT =3D char; _Traits =3D std::char_traits; std::basic_ostream<_CharT, _Traits>::__ostream_type= =3D std::basic_ostream] 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 =E2=80=98Student=E2=80=99 to =E2=80=98= unsigned int=E2=80=99 /home/manuel/test1/195333M/install/include/c++/4.8.0/ostream:203:7: note: std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_Ch= arT, _Traits>::operator<<(long long int) [with _CharT =3D char; _Traits =3D std::char_traits; std::basic_ostream<_CharT, _Traits>::__ostream_type= =3D std::basic_ostream] 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 =E2=80=98Student=E2=80=99 to =E2=80=98= long long int=E2=80=99 /home/manuel/test1/195333M/install/include/c++/4.8.0/ostream:207:7: note: std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_Ch= arT, _Traits>::operator<<(long long unsigned int) [with _CharT =3D char; _Traits= =3D std::char_traits; std::basic_ostream<_CharT, _Traits>::__ostream_type= =3D std::basic_ostream] 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 =E2=80=98Student=E2=80=99 to =E2=80=98= long long unsigned int=E2=80=99 /home/manuel/test1/195333M/install/include/c++/4.8.0/ostream:222:7: note: std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_Ch= arT, _Traits>::operator<<(double) [with _CharT =3D char; _Traits =3D std::char_traits; std::basic_ostream<_CharT, _Traits>::__ostream_type= =3D std::basic_ostream] operator<<(double __f) ^ /home/manuel/test1/195333M/install/include/c++/4.8.0/ostream:222:7: note: = no known conversion for argument 1 from =E2=80=98Student=E2=80=99 to =E2=80=98= double=E2=80=99 /home/manuel/test1/195333M/install/include/c++/4.8.0/ostream:226:7: note: std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_Ch= arT, _Traits>::operator<<(float) [with _CharT =3D char; _Traits =3D std::char_traits; std::basic_ostream<_CharT, _Traits>::__ostream_type= =3D std::basic_ostream] operator<<(float __f) ^ /home/manuel/test1/195333M/install/include/c++/4.8.0/ostream:226:7: note: = no known conversion for argument 1 from =E2=80=98Student=E2=80=99 to =E2=80=98= float=E2=80=99 /home/manuel/test1/195333M/install/include/c++/4.8.0/ostream:234:7: note: std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_Ch= arT, _Traits>::operator<<(long double) [with _CharT =3D char; _Traits =3D std::char_traits; std::basic_ostream<_CharT, _Traits>::__ostream_type= =3D std::basic_ostream] 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 =E2=80=98Student=E2=80=99 to =E2=80=98= long double=E2=80=99 /home/manuel/test1/195333M/install/include/c++/4.8.0/ostream:247:7: note: std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_Ch= arT, _Traits>::operator<<(const void*) [with _CharT =3D char; _Traits =3D std::char_traits; std::basic_ostream<_CharT, _Traits>::__ostream_type= =3D std::basic_ostream] 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 =E2=80=98Student=E2=80=99 to =E2=80=98= const void*=E2=80=99 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 =3D char; _Traits =3D std::char_traits; std::basic_ostream<_CharT, _Traits>::__streambuf_type =3D std::basic_streambuf] 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 =E2=80=98Student=E2=80=99 to =E2=80=98std::basic_ostream::__streambuf_type* {aka std::basic_stream= buf*}=E2=80=99 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 std::basic_ostream& std::operator<<(std::basic_ostream&, const unsigned char*) operator<<(basic_ostream& __out, const unsigned char* _= _s) ^ /home/manuel/test1/195333M/install/include/c++/4.8.0/ostream:550:5: note:= =20=20 template argument deduction/substitution failed: test.cc:15:16: note: cannot convert =E2=80=98me=E2=80=99 (type =E2=80=98S= tudent=E2=80=99) to type =E2=80=98const unsigned char*=E2=80=99 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 std::basic_ostream& std::operator<<(std::basic_ostream&, const signed char*) operator<<(basic_ostream& __out, const signed char* __s) ^ /home/manuel/test1/195333M/install/include/c++/4.8.0/ostream:545:5: note:= =20=20 template argument deduction/substitution failed: test.cc:15:16: note: cannot convert =E2=80=98me=E2=80=99 (type =E2=80=98S= tudent=E2=80=99) to type =E2=80=98const signed char*=E2=80=99 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 std::basic_ostream& std::operator<<(std::basic_ostream&, const char*) operator<<(basic_ostream& __out, const char* __s) ^ /home/manuel/test1/195333M/install/include/c++/4.8.0/ostream:532:5: note:= =20=20 template argument deduction/substitution failed: test.cc:15:16: note: cannot convert =E2=80=98me=E2=80=99 (type =E2=80=98S= tudent=E2=80=99) to type =E2=80=98const char*=E2=80=99 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 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 =E2=80=98me=E2=80=99 (type =E2=80=98S= tudent=E2=80=99) to type =E2=80=98const char*=E2=80=99 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 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:= =20=20 template argument deduction/substitution failed: test.cc:15:16: note: mismatched types =E2=80=98const _CharT*=E2=80=99 and= =E2=80=98Student=E2=80=99 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 std::basic_ostream& std::operator<<(std::basic_ostream&, unsigned char) operator<<(basic_ostream& __out, unsigned char __c) ^ /home/manuel/test1/195333M/install/include/c++/4.8.0/ostream:495:5: note:= =20=20 template argument deduction/substitution failed: test.cc:15:16: note: cannot convert =E2=80=98me=E2=80=99 (type =E2=80=98S= tudent=E2=80=99) to type =E2=80=98unsigned char=E2=80=99 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 std::basic_ostream& std::operator<<(std::basic_ostream&, signed char) operator<<(basic_ostream& __out, signed char __c) ^ /home/manuel/test1/195333M/install/include/c++/4.8.0/ostream:490:5: note:= =20=20 template argument deduction/substitution failed: test.cc:15:16: note: cannot convert =E2=80=98me=E2=80=99 (type =E2=80=98S= tudent=E2=80=99) to type =E2=80=98signed char=E2=80=99 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 std::basic_ostream& std::operator<<(std::basic_ostream&, char) operator<<(basic_ostream& __out, char __c) ^ /home/manuel/test1/195333M/install/include/c++/4.8.0/ostream:484:5: note:= =20=20 template argument deduction/substitution failed: test.cc:15:16: note: cannot convert =E2=80=98me=E2=80=99 (type =E2=80=98S= tudent=E2=80=99) to type =E2=80=98char=E2=80=99 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 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:= =20=20 template argument deduction/substitution failed: test.cc:15:16: note: cannot convert =E2=80=98me=E2=80=99 (type =E2=80=98S= tudent=E2=80=99) to type =E2=80=98char=E2=80=99 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 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:= =20=20 template argument deduction/substitution failed: test.cc:15:16: note: deduced conflicting types for parameter =E2=80=98_Ch= arT=E2=80=99 (=E2=80=98char=E2=80=99 and =E2=80=98Student=E2=80=99) 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:27= 55:5: note: template std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_Ch= arT, _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:27= 55:5: note: template argument deduction/substitution failed: test.cc:15:16: note: =E2=80=98Student=E2=80=99 is not derived from =E2=80= =98const std::basic_string<_CharT, _Traits, _Alloc>=E2=80=99 std::cout << me << "\n"; ^