I have the following situation:
A function creates an array of strings and then passes this to a bunch of other functions. These other functions should not modify neither pointers pointed to by the outer pointer nor the strings themselves, so I made them const.
Minimal example:
void function(const char * const *arr) {
/* Do something useful */
}
int main(void) {
char **x;
/* fill x and *x */
function(x);
}
When compiling with gcc or clang this gives me a warning, that x is converted to an incompatible pointer type.
While I understand why the pointer type is incompatible if I remove the second const in the parameter list of function (explained here: Why does passing char** as const char** generate a warning?), I do not understand why it is incompatible with the const.
Compiling with a c++-Compiler does not give me the warning (See comparison here: https://gcc.godbolt.org/z/YND5U7)