https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77577
Bug ID: 77577 Summary: missing warnings about too few array elements Product: gcc Version: 7.0 Status: UNCONFIRMED Severity: enhancement Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: drepper.fsp+rhbz at gmail dot com Target Milestone: --- With a declaration of 'f' as in the following code the function implementation can assume that at least the given number of elements are available in the array. According to ISO C: If the keyword static also appears within the [ and ] of the array type derivation, then for each call to the function, the value of the corresponding actual argument shall provide access to the first element of an array with at least as many elements as specified by the size expression. Given the following code gcc (in trunk and previous versions) does not emit a warning. It should be possible to emit one. Especially with recent changes which make __builtin_object_size usable even without optimization. int f(int ss[static 5]); int g() { int ar[2]; return f(ar); }