http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50584

             Bug #: 50584
           Summary: No warning for passing small array to C99 static array
                    declarator
    Classification: Unclassified
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassig...@gcc.gnu.org
        ReportedBy: i...@airs.com


C99 introduced the idea of using static in an array declarator in a function
prototype parameter.  My reading of the standard is that using static means
that the actual argument must be at least that size.  GCC should at least issue
a warning when that requirement is clearly violated.

For example, this program


extern void bar (void *a[static 6]);
void foo() {
  void *a1;
  void *a2[5];
  void *a3[6];
  void *a4[10];

  bar (&a1);
  bar (a2);
  bar (a3);
  bar (a4);
}

should issue a warning, or perhaps even an error, for the first two calls to
bar, as the compiler can clearly see that the values are not large enough.

Reply via email to