3 ms·
If you compile assert(foo(bar) == 0); with NDEBUG, foo will never even be called. I've seen some funky bugs from this in the past, like people calling malloc
by sebcat 13y ago
If you compile
assert(foo(bar) == 0);
with NDEBUG, foo will never even be called. I've seen some funky bugs from this in the past, like people calling malloc inside an assertion... Works great during dev, release build has NDEBUG defined, no test coverage... You get the picture.
A better idea would be to capture the return value in a var and do the assert on the var.
- halayli 13y agoYes I understand that foo() won't be called if you defined NDEBUG. But when compiling lthread, NDEBUG is not defined anywhere in the code / makefiles so it's guaranteed to be called and I want to assert the returned value.