Unlike Java, in C/C++ following is allowed:
int* foo () { if(x) return p; // what if control reaches here }
This oft
Use -Wall flag in gcc.
-Wall
gcc
warning: control reaches end of non-void function
EDIT: or more specifically -Wreturn-type.
-Wreturn-type