[llvm-bugs] [Bug 40177] New: c11: Accepts ill-formed program with inline function definition containing modifiable variable with static storage duration.

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Dec 28 13:19:49 PST 2018


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

            Bug ID: 40177
           Summary: c11: Accepts ill-formed program with inline function
                    definition containing modifiable variable with static
                    storage duration.
           Product: clang
           Version: trunk
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: anders.granlund.0 at gmail.com
                CC: htmldeveloper at gmail.com, llvm-bugs at lists.llvm.org,
                    neeilans at live.com, richard-llvm at metafoo.co.uk

Test case (prog.c):

  inline void f()
  {
    static int x;
  }

  int main()
  {
  }

Compilation command line:

  clang prog.c -Wall -Wextra -std=c11 -pedantic-errors 

Observed behaviour:

  No error message outputed. Only a warning message outputed.

Expected behaviour:

  An error message outputed.

  The program violates 6.7.4/3:

    "An inline definition of a function with external linkage shall not contain
     a definition of a modifiable object with static or thread storage
duration,
     and shall not contain a reference to an identifier with internal linkage."

  Since  -pedantic-errors  is used we should get an error instead of a warning.

Note:

  GCC gives the expected error message.

-- 
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/20181228/3737d7f3/attachment.html>


More information about the llvm-bugs mailing list