There is no way for the compiler to know what you are trying to do with the pointer you are returning in func2.
You could as well be returning an instance for an array, for example:
int *func2() {
int a = 3;
int *p = &a;
/*some useful stuff*/
if (some_criteria)
p = new int[10];
return p;
}
Because the compiler does not have the power to evaluate the semantics of the returned pointer.