codeql-coding-standards icon indicating copy to clipboard operation
codeql-coding-standards copied to clipboard

`RULE-1-2`: False positives reported for variable length arrays

Open lcartey opened this issue 5 months ago • 0 comments

Affected rules

  • RULE-1-2

Description

This rule currently flags all variable length arrays, and arrays without a specified size, but which are initialized. However, various types of variable length arrays are permitted in C99 onwards.

Example

void example_function(int n, int x[n]) { // COMPLIANT[FALSE_POSITIVE]
  struct S {
    int x1[n]; // NON_COMPLIANT
    int x2[]; // COMPLIANT[FALSE_POSITIVE]
  };

  int y[] = {1,2,3}; // COMPLIANT[FALSE_POSITIVE]
}

lcartey avatar Sep 19 '24 10:09 lcartey