[Bug c/50584] New: No warning for passing small array to C99 static array declarator
ian at airs dot com
gcc-bugzilla@gcc.gnu.org
Fri Sep 30 18:15:00 GMT 2011
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: unassigned@gcc.gnu.org
ReportedBy: ian@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.
More information about the Gcc-bugs
mailing list