The bit is late, but you can also do this without warning with warnings:
static char buf[8]; void foo(){ const char* ptr = buf; char* q = buf + (ptr-buf); }
As a result, you get q = buf + ptr - buf = ptr + buf - buf = ptr , but with the constant buf .
(Yes, this allows you to remove const from any pointer in general, const is an advisory tool, not a security mechanism.)
David x
source share