Ah, I see what you're getting at (I think)
Code:
void func ( char **helper, const char *array ) {
helper[0] = array;
}
int main ( ) {
char msg[] = "hello world";
char *helper[2];
func( &helper, msg );
helper[0][0] = 'H'; // modifies msg[0]
func( &helper, "string constant" );
helper[0][0] = 'S'; // segfault?
return 0;
}
In the first instance, the const should just be diagnosing local attempts to modify the variable. The input array isn't const to begin with, so it should be reasonable to expect to be able to modify it afterwards via the return result. Unfortunately, the const is a 'sticky' attribute and it propagates through assignments.
In the second instance, it's saying that the input is really const and that should be propagated to other pointers as well. Indeed, it would be nice to diagnose helper[0][0] = 'S' at compile time rather than at run-time (or worse, some random crash much later on).
Ideally of couse, we would have had
const char *helper[2];
func( &helper, "string constant" );
But then the compiler would have complained about the first parameter losing const!
It's like we need
void func ( char **helper, char *array );
void func ( const char **helper, const char *array );
but C doesn't have anything like that kind of overloading ability to be able to resolve all the possible meanings.