Is the following program really valid C++?
#include <string>
int main () {
std::string x = x;
return 0;
}
It compiles without errors or warnings with g++ and just seg faults when run.
If I change the type of x to int, it gives me a warning at least: warning: "x" is used uninitialized in this function [-Wuninitialized].
I would have expected the line to be invalid because x has not been declared before.