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: unassignedclangb...@nondot.org
          Reporter: ch3r...@openwall.com
                CC: llvm-bugs@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.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to