Ask HN: Why can't C++ compilers find this error?
Debugging some 3rd party library I ran into a "reference a stack object that no longer exists" error. repo #include <iostream> int* f() { int x = 4; int* xp = &x; return xp; } int main() { int* p = f(); std::cout << *p; } Without giving it much thought, why is this hard for a modern C++ compiler to detect?Note that gcc will detect some of...