Skip to content

Instantly share code, notes, and snippets.

@netj
Last active August 29, 2015 14:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save netj/9218227b463114b78632 to your computer and use it in GitHub Desktop.
Save netj/9218227b463114b78632 to your computer and use it in GitHub Desktop.
#include <cassert>
int main() {
// The following line may crash the code
// Try: g++ assert.cc && ./a.out
assert(false);
// But only if it weren't compiled with NDEBUG macro defined.
// Now try: g++ -DNDEBUG assert.cc && ./a.out
return 0;
// See: http://en.cppreference.com/w/cpp/error/assert
// See: http://www.cplusplus.com/reference/cassert/assert/
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment