#include
int* f() { int x = 4; int* xp = &x; return xp; }
int main() {
int* p = f();
std::cout
Without giving it much thought, why is this hard for a modern C++ compiler to detect?Note that gcc will detect some of these
#include
int main() {
int* p;
{ int j = 123; p = &j; }
std::cout
Gets an error in gcc (not in clang)I know this type of issue is a strong reason people prefer rust but I'm still surprised a modern C++ compile doesn't find these issues. Is it an intractable issue?