In main.cpp the following line within ConnectBlock has side effects which would be skipped if -DNDEBUG were to be defined.
It should be, indeed, but we don't support compiling without asserts. This is a known wart. There are a couple of other similar places that ought to be fixed. I might as well go fix it.