[llvm-bugs] [Bug 27054] New: Clang compiles a return statement with an expression in a void function (illegal under C90 6.6.6.4) with -std=c90 -pedantic
via llvm-bugs
llvm-bugs at lists.llvm.org
Thu Mar 24 07:50:05 PDT 2016
https://llvm.org/bugs/show_bug.cgi?id=27054
Bug ID: 27054
Summary: Clang compiles a return statement with an expression
in a void function (illegal under C90 6.6.6.4) with
-std=c90 -pedantic
Product: clang
Version: unspecified
Hardware: PC
OS: Linux
Status: NEW
Keywords: accepts-invalid
Severity: normal
Priority: P
Component: Frontend
Assignee: unassignedclangbugs at nondot.org
Reporter: ryao at gentoo.org
CC: llvm-bugs at lists.llvm.org
Classification: Unclassified
Created attachment 16081
--> https://llvm.org/bugs/attachment.cgi?id=16081&action=edit
Test case where Clang 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`.
This was also filed against GCC, which exhibits the same behavior:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70400
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20160324/1a232c4d/attachment-0001.html>
More information about the llvm-bugs
mailing list