Paragraph 6.7.3.8 of the C99 spec states
If the specification of an array type includes any type qualifiers, the element type is so-qualified, not the array ty
Possible workaround for the C programmer (but not the compiler designer):
gcc with -Wcast-qual
does not complain about this:
void g(const double *ap, int n)
{
int i;
struct box
{
double a[n];
};
const struct box *s = (const struct box *)ap;
for (i=0; ia[i]);
/* ... */
}
}
Even if it's not very elegant. The trailing array member a
also has a slightly different meaning between C89 and C99, but at least you get the intended effect.