[LLVMbugs] [Bug 13881] New: Clang incorrectly accepts zero-length arrays that are not flexible array members

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Wed Sep 19 15:45:59 PDT 2012


http://llvm.org/bugs/show_bug.cgi?id=13881

             Bug #: 13881
           Summary: Clang incorrectly accepts zero-length arrays that are
                    not flexible array members
           Product: clang
           Version: 3.1
          Platform: Macintosh
        OS/Version: MacOS X
            Status: NEW
          Severity: normal
          Priority: P
         Component: Frontend
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: kyle at omnigroup.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified


Created attachment 9237
  --> http://llvm.org/bugs/attachment.cgi?id=9237
Test case showing incorrect acceptance of zero length array

Clang should not accept declarations of the form `int foo[0]` unless they are
declaring C99 flexible array members. Per §6.7.5.2 ¶1 of the C99 standard:

"""In addition to optional type qualifiers and the keyword static, the [ and ]
may delimit an expression or *. If they delimit an expression (which specifies
the size of an array), the expression shall have an integer type. If the
expression is a constant expression, it shall have a value greater than
zero."""

The attached file demonstrates this bug. With optimization disabled, this code
prints a non-NULL pointer value. With -O1 or higher, it prints a null pointer
value.

-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list