Skip to content

Instantly share code, notes, and snippets.

@MLKrisJohnson
Last active November 18, 2019 13:02
Show Gist options
  • Save MLKrisJohnson/fa00fc1819ae75def4e5e60dab6fcf46 to your computer and use it in GitHub Desktop.
Save MLKrisJohnson/fa00fc1819ae75def4e5e60dab6fcf46 to your computer and use it in GitHub Desktop.
Simple C++ program that immediately crashes. Useful for playing with debuggers and other diagnostic tools.
#include <iostream>
int main(int argc, const char** argv)
{
// This should force a segmentation fault on most platforms
*(volatile char *)0 = 0x77;
std::cerr << "The program didn't crash." << std::endl;
return 0;
}
crash: crash.cpp
# Run 'make test' to build and run the program
test: crash
./crash
.PHONY: test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment