Author

Topic: assert(...) with side effects (Read 509 times)

legendary
Activity: 1526
Merit: 1129
December 02, 2013, 05:39:49 PM
#3
It's probably better to just define a custom CHECK macro that is always active. It's better to crash the node in production than to enter an undefined state.
staff
Activity: 4158
Merit: 8382
December 02, 2013, 03:18:42 PM
#2
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.
hero member
Activity: 770
Merit: 566
fractally
December 02, 2013, 02:09:14 PM
#1
In main.cpp the following line within ConnectBlock has side effects which would be skipped if -DNDEBUG were to be defined. 

Code:
assert(view.SetBestBlock(pindex->GetBlockHash()));

Seems to me the code should be

Code:
bool success = view.SetBestBlock(pindex->GetBlockHash());
assert(success);

Jump to: