[LLVMbugs] [Bug 5185] New: C99 [*] VLA notation should be disallowed in function definitions

bugzilla-daemon at cs.uiuc.edu bugzilla-daemon at cs.uiuc.edu
Tue Oct 13 23:27:36 PDT 2009


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

           Summary: C99 [*] VLA notation should be disallowed in function
                    definitions
           Product: clang
           Version: unspecified
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Semantic Analyzer
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: holm at liacs.nl
                CC: llvmbugs at cs.uiuc.edu


The notation [*] is by the C99 standard only allowed in function prototypes. 
GCC reports incorrect use of [*] like: "vla.c:22: error: ‘[*]’ not allowed
in other than function prototype scope"

Clang (at least the one installed in OS X 10.6 devtools) happily accepts this
even in the argument lists of a function definition.

---------------
See C99 standard document section 6.7.5.3 paragraph 12:

"If the function declarator is not part of a definition of that function,
parameters may have incomplete type and may use the [*] notation in their
sequences of declarator specifiers to specify variable length array types."
---------------

I suggest reporting violations of this as something in the style of: "error:
VLA length not bound in definition" and not the "error: [*] not allowed" as GCC
does. The GCC report is not very suggestive about what you can do to fix the
error.

Example and simple test case:

void foo(int a[*]); // OK, this is a function prototype


// NOT valid C99, VLA 'a' must have its length bound to
// another parameter or constant when used in a function
// definition
void foo(int a[*]) 
{

}


-- 
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