[Bug c++/66696] New: confusing diagnostic on a friend main definition returning void
msebor at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Mon Jun 29 18:30:00 GMT 2015
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66696
Bug ID: 66696
Summary: confusing diagnostic on a friend main definition
returning void
Product: gcc
Version: 5.1.0
Status: UNCONFIRMED
Severity: minor
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: msebor at gcc dot gnu.org
Target Milestone: ---
When main is defined with the wrong return type, GCC issues a clear message
pointing out the error:
$ cat u.c && ~/bin/gcc-5.1.0/bin/g++ -c -fno-diagnostics-show-caret -o/dev/null
u.c
void main (void) { }
u.c:1:16: error: ‘::main’ must return ‘int’
But when main is defined to return void as a friend function of a class GCC
issues the following cryptic error message. In addition, in this case GCC
makes it possible to demote the error to a warning via -fpermissive.
GCC should treat these cases the same way (as Clang does).
$ cat u.c && ~/bin/gcc-5.1.0/bin/g++ -c -o/dev/null u.cstruct S {
friend void main (void) { }
};
u.c: In function ‘void main()’:
u.c:2:31: error: return-statement with a value, in function returning 'void'
[-fpermissive]
friend void main (void) { }
^
More information about the Gcc-bugs
mailing list