This is a feature of the MSVC runtime that does some checks at runtime in debug mode and displays these dialogs, i doubt gcc offers something like that.
And your code example should not crash, you just output the value of that uninitialized pointer, this doesnt crash but just displays its random value. It would very likely crash if you would dereference that pointer, unless by chance the random value points to a valid address you have access to