Don't assert(foo()) where foo has side effects.
From assert(3):
If the macro
NDEBUGis defined at the moment<assert.h>was last included, the macroassert()generates no code, and hence does nothing at all.
Bitcoin currently cannot be compiled without assertions, but we shouldn't rely on that.