From a60e344c2f266002ae7cd40ddc12d3f8263a8be9 Mon Sep 17 00:00:00 2001 From: Owen Shepherd Date: Mon, 31 Dec 2012 00:29:06 +0000 Subject: [PATCH] assert: for assert(x), mark !x case as _PDCLIB_UNREACHABLE --- includes/assert.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/includes/assert.h b/includes/assert.h index ca0022d..cb5c47e 100644 --- a/includes/assert.h +++ b/includes/assert.h @@ -20,7 +20,10 @@ void _PDCLIB_assert89( char const * const ); #undef assert #ifdef NDEBUG -#define assert( ignore ) ( (void) 0 ) +#define assert( ignore ) do { \ + if(!(expression)) { _PDCLIB_UNREACHABLE; } \ + } while(0) + #elif _PDCLIB_C_MIN(99) #define assert(expression) \ do { if(!(expression)) { \ @@ -29,8 +32,10 @@ void _PDCLIB_assert89( char const * const ); ", file " __FILE__ \ ", line " _PDCLIB_symbol2string( __LINE__ ) \ "." _PDCLIB_endl ); \ + _PDCLIB_UNREACHABLE; \ } \ } while(0) + #else #define assert(expression) \ do { if(!(expression)) { \ @@ -38,6 +43,7 @@ void _PDCLIB_assert89( char const * const ); ", file " __FILE__ \ ", line " _PDCLIB_symbol2string( __LINE__ ) \ "." _PDCLIB_endl ); \ + _PDCLIB_UNREACHABLE; \ } \ } while(0) #endif -- 2.40.0