[llvm-bugs] [Bug 28407] New: Invalid C accepted: flexible array member in struct with only unnamed member

via llvm-bugs llvm-bugs at lists.llvm.org
Sun Jul 3 09:40:37 PDT 2016


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

            Bug ID: 28407
           Summary: Invalid C accepted: flexible array member in struct
                    with only unnamed member
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: ch3root at openwall.com
                CC: llvm-bugs at lists.llvm.org
    Classification: Unclassified

A flexible array member is only permitted in a struct when the struct contains
another _named_ member:

C11, 6.7.2.1p3: "A structure or union shall not contain a member with
incomplete or function type [...], except that the last member of a structure
with more than one named member may have incomplete array type"

This is a constraint violation and must be diagnosed.

Source code:

----------------------------------------------------------------------
int main()
{
  struct s {
    int :1;
    int a[];
  };
}
----------------------------------------------------------------------

Results:

----------------------------------------------------------------------
$ clang -std=c11 -Weverything -O3 test.c && ./a.out
----------------------------------------------------------------------

clang version: clang version 3.9.0 (trunk 271312)

-- 
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/20160703/208b819a/attachment.html>


More information about the llvm-bugs mailing list