This is the mail archive of the
mailing list for the GCC project.
warning about const multidimensional array as function parameter
- From: Martin Uecker <uecker at eecs dot berkeley dot edu>
- To: gcc at gcc dot gnu dot org
- Date: Mon, 13 Oct 2014 14:05:09 -0700
- Subject: warning about const multidimensional array as function parameter
- Authentication-results: sourceware.org; auth=none
although this is a problem of the C standard, I still
find it annoying that the following code produces warnings
about incompatible pointer types (this has been discussed
before, see below):
extern void test(const double x);
const double (*y) = x;
Could we have an option to turn these warnings off?
Or, even better, have these warnings only with '-pedantic'?
I could try to come up with a patch...
This is not allowed because in C the qualifier always
belongs to the element type, and the allowed pointer
conversion rules do not include this case - which I assume
is an oversight of the standards committee.
Converting a pointer to an array to a pointer to a
constant array (i.e. an array with constant element type)
seems to be a perfectly reasonable and safe thing to do.
This is different from the case of converting a pointer
to a pointer, e.g. char** to const char** which is unsafe.