public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/50330] New: Misleading error message with struct declaration
@ 2011-09-08 14:58 rui.maciel at gmail dot com
  2011-09-08 15:14 ` [Bug c/50330] " redi at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: rui.maciel at gmail dot com @ 2011-09-08 14:58 UTC (permalink / raw)
  To: gcc-bugs

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: unassigned@gcc.gnu.org
        ReportedBy: rui.maciel@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.


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

end of thread, other threads:[~2011-09-09  1:10 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-09-08 14:58 [Bug c/50330] New: Misleading error message with struct declaration rui.maciel at gmail dot com
2011-09-08 15:14 ` [Bug c/50330] " redi at gcc dot gnu.org
2011-09-08 15:18 ` redi at gcc dot gnu.org
2011-09-09  7:24 ` bugzilla at bsb dot me.uk

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).