Neither gcc 5 nor clang 3.6 give warnings where the constraints of the restrict
qualifier are violated, even when called with -Wall
. Consider the following code fragment:
extern void f(char *restrict p, char *restrict q);
void g(char *p)
{
f(p, p);
}
Naively, I'd expect that the violation can be determined statically, and I was expecting that -Wall
would give a warning. Have I missed a flag somewhere, or is there some problem with giving warnings that I'm not seeing?
void f(char *p, char *q);
. Apparently no compiler optimizes the calling code based on the presence ofrestrict
either. Related thread – Gildagildas