diff --git a/include/bits/assert.h b/include/bits/assert.h index 3a8c1b0017ce662ce62a3405138b6a967b46c4ae..2daab428128f4dbbaa8e1e787cda506b9ed1b664 100644 --- a/include/bits/assert.h +++ b/include/bits/assert.h @@ -2,11 +2,10 @@ #define _BITS_ASSERT_H #ifdef NDEBUG -# define assert(cond) +# define assert(cond) (void) 0 #else -# define assert(cond) if (!(cond)) { \ - __assert(__func__, __FILE__, __LINE__, #cond); \ - } +# define assert(cond) \ + ((void)((cond) || (__assert(__func__, __FILE__, __LINE__, #cond), 0))) #endif #endif diff --git a/tests/assert.c b/tests/assert.c index 320737f2f61a8f7c727d6f8036a19e0bc3d2c6ac..7f98bbe9c578705b5e79f799121253ad9b6b8765 100644 --- a/tests/assert.c +++ b/tests/assert.c @@ -5,9 +5,12 @@ int main() { assert(1 == 1); assert(1 + 1 == 2); - puts("yay!"); + if (assert(0 == 0), 1) { + puts("groovy!"); + } + //This fails, but I can't test it because that'd //make the test fail lol //assert(42 == 1337); diff --git a/tests/expected/assert.stdout b/tests/expected/assert.stdout index 3650d378d39e967450d22b79e2dd2774a6aae30f..028678d98788d3147a632bd6b95012ad135ebe92 100644 --- a/tests/expected/assert.stdout +++ b/tests/expected/assert.stdout @@ -1 +1,2 @@ yay! +groovy!