http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50330
Bug #: 50330 Summary: Misleading error message with struct declaration Classification: Unclassified Product: gcc Version: 4.5.2 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c AssignedTo: unassig...@gcc.gnu.org ReportedBy: rui.mac...@gmail.com struct t { int x; } int main(void) { return 0; } This code, compiled with gcc, produces the following error message: <message> rui@Kubuntu:tmp$ gcc main.c main.c:5:1: error: two or more data types in declaration specifiers main.c: In function ‘main’: main.c:7:10: error: incompatible types when returning type ‘int’ but ‘struct t’ was expected </message> The same code, when compiled with g++, produces the following error message: <message> rui@Kubuntu:tmp$ g++ main.c main.c:1:1: error: new types may not be defined in a return type main.c:1:1: note: (perhaps a semicolon is missing after the definition of ‘t’) main.c:5:14: error: two or more data types in declaration of ‘main’ </message> gcc's error message is cryptic and doesn't help the user. g++'s error message, on the other hand, although it is still cryptic it provides useful clues to the user, which makes it considerably more helpful. Nonetheless, both error messages are needlessly cryptic and could be considerable improved, so that the user gets a much clearer idea on where the error lies. As a comparison, here is clang's error message: <message> rui@Kubuntu:tmp$ clang main.c main.c:3:2: error: expected ';' after struct } ^ ; 1 error generated. </message> This error message is clear, concise and to the point. It would be great if GCC improved the error message for this scenario.