Fix oops() to not have UB.
Writing to NULL is undefined behavior and it is legal for the compiler to simply remove it; clang will do so. abort() or __builtin_trap() would produce the desirable result. abort() is used as it is more portable.pull/3/head
parent
1cd2e2be2f
commit
604c4bbea3
|
@ -44,8 +44,13 @@
|
|||
#endif
|
||||
|
||||
// Debugging functions
|
||||
#ifdef NDEBUG
|
||||
#define oops() do { dbp("oops at line %d, file %s\n", __LINE__, __FILE__); \
|
||||
if(0) *(char *)0 = 1; exit(-1); } while(0)
|
||||
exit(-1); } while(0)
|
||||
#else
|
||||
#define oops() do { dbp("oops at line %d, file %s\n", __LINE__, __FILE__); \
|
||||
abort(); } while(0)
|
||||
#endif
|
||||
|
||||
#ifndef min
|
||||
# define min(x, y) ((x) < (y) ? (x) : (y))
|
||||
|
|
Loading…
Reference in New Issue