[cfe-dev] no warning for arrays that are too short?
Sean McBride
sean at rogue-research.com
Wed Dec 5 17:24:05 PST 2012
Hi all,
I was sad to discover that the compiler does not warn here:
---------
static void Set4 (const double arg[4])
{
printf("%f %f %f %f \n", arg[0], arg[1], arg[2], arg[3]);
}
int main (void)
{
double array[3] = {1.0, 2.0, 3.0};
Set4(array);
return 0;
}
---------
I'm admittedly naive, but I would have thought it could see that the passed array has fewer elements than the function expects...
Cheers,
Sean
More information about the cfe-dev
mailing list