NSAssert in blocks

From NSNotificationCenter with blocks considered harmful:

what is wrong here? I’ll give you a hint: if you test in Release mode, it works fine. It only fails in Debug mode.

Give up?

Here’s the answer:

NSAssert(counter==oldCounterValue+1, @”Atomicity guarantee violated.”);

See, NSAssert is a macro. A macro that expands to this:

do {
    __PRAGMA_PUSH_NO_EXTRA_ARG_WARNINGS
    if (!(condition)) {
        [[NSAssertionHandler currentHandler] handleFailureInMethod:_cmd
        object:self file:[NSString stringWithUTF8String:__FILE__]
            lineNumber:__LINE__ description:(desc), ##__VA_ARGS__];
    }               
        __PRAGMA_POP_NO_EXTRA_ARG_WARNINGS
} while(0)

See there? Big fat self. Ergo, retain cycle, ergo test failure