Is this a clang bug?
#include <stdlib.h>
long func(int *p, long size) {
int *q = (int*)realloc(p,size);
if (p == q) {
*p = 1;
*q = 2;
return *p + *q;
}
return 0;
}
func() returns 3 when realloc ends up not moving anything. This is obviously "wrong", but is it a bug?
realloc() return value aliases to nothing. But after verifying the pointer is identical, does this still hold?