[llvm-bugs] [Bug 27055] 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:59:25 PDT 2016


https://llvm.org/bugs/show_bug.cgi?id=27055

            Bug ID: 27055
           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: 3.8
          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 16082
  --> https://llvm.org/bugs/attachment.cgi?id=16082&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

Clang will only emit a warning when -pendantic is specified and adding -std=c90
does not change the behavior to a warning. The GCC 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

Also, I tested the attached minimal test case against both GCC 4.9.3 and Clang
3.8.0. kate in ##c on freenode tested against TenDRA while the reporter for the
sudo bug caught the issue in sudo with Sun Studio 12.

-- 
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/6f907d0a/attachment.html>


More information about the llvm-bugs mailing list