This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/70400] New: GCC compiles a return statement with an expression in a void function (illegal under C90 6.6.6.4) with -std=c90 -pedantic
- From: "ryao at gentoo dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Thu, 24 Mar 2016 14:51:14 +0000
- Subject: [Bug c/70400] New: GCC compiles a return statement with an expression in a void function (illegal under C90 6.6.6.4) with -std=c90 -pedantic
- Auto-submitted: auto-generated
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70400
Bug ID: 70400
Summary: GCC compiles a return statement with an expression in
a void function (illegal under C90 6.6.6.4) with
-std=c90 -pedantic
Product: gcc
Version: unknown
Status: UNCONFIRMED
Keywords: diagnostic
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: ryao at gentoo dot org
Target Milestone: ---
Created attachment 38081
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=38081&action=edit
Test case where GCC allows a void function to return an expression
ISO C90 6.6.6.4 says that "A return statement with an expression shall not
appear in a function whose return type is void."
Both Sun Studio and the TenDRA make this a build failure as the specification
requires while Clang does what GCC does. The sudo project had a bug filed
agaisnt it because of Sun Studio:
https://bugzilla.sudo.ws/show_bug.cgi?id=727
GCC will only emit a warning when -pendantic is specified and adding -std=c90
does not change the behavior to a warning. The documentation for -pedantic
clearly states that things disallowed by the specification emit errors:
https://gcc.gnu.org/onlinedocs/gcc-4.9.3/gcc/Warning-Options.html
This probably should be a warning even without `-pendantic`.