Bitcoin Forum
May 18, 2024, 01:05:22 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: assert(...) with side effects  (Read 512 times)
bytemaster (OP)
Hero Member
*****
Offline Offline

Activity: 770
Merit: 566

fractally


View Profile WWW
December 02, 2013, 06: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);


https://fractally.com - the next generation of decentralized autonomous organizations (DAOs).
gmaxwell
Moderator
Legendary
*
expert
Offline Offline

Activity: 4172
Merit: 8421



View Profile WWW
December 02, 2013, 07: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.
Mike Hearn
Legendary
*
expert
Offline Offline

Activity: 1526
Merit: 1129


View Profile
December 02, 2013, 09: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.
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!