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.
This commit is contained in:
parent
1cd2e2be2f
commit
604c4bbea3
@ -44,8 +44,13 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Debugging functions
|
// Debugging functions
|
||||||
|
#ifdef NDEBUG
|
||||||
#define oops() do { dbp("oops at line %d, file %s\n", __LINE__, __FILE__); \
|
#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
|
#ifndef min
|
||||||
# define min(x, y) ((x) < (y) ? (x) : (y))
|
# define min(x, y) ((x) < (y) ? (x) : (y))
|
||||||
|
Loading…
Reference in New Issue
Block a user