static char buf[8];
void foo(){
const char* ptr = buf;
/* ... */
char* q = (char*)ptr;
}
The above snippet will generate \"warnin
Bit late, but you can also do this without mucking with warnings at all:
static char buf[8];
void foo(){
const char* ptr = buf;
/* ... */
char* q = buf + (ptr-buf);
}
You end up with q = buf + ptr - buf = ptr + buf - buf = ptr, but with buf's constness.
(Yes, this allows you to remove const from any pointer at all; const is advisory, not a security mechanism.)