I'm facing a strange behaviour in my windows 10 development environment.
I compile the following code (mingv gcc-8.1.0)
int main(){
char* x = nullptr;
std::cout<<*x<<std::endl;
return 0;
}
When I run this program in a cmd or powershell window, it outputs a blank line, waits for a bunch of seconds and then returns to prompt.
I'd love to have it print "segmentation fault" and exit immediately, as god intended.
If I run the program in GDB the error is shown correctly (Thread 1 received signal SIGSEGV, Segmentation fault.
).
Could someone please explain why it does this and if there is a way to obtain the desired behaviour?