util: Add Assume() identity function#20255
Conversation
|
Concept ACK. It's mildly interesting that we're sort of reinventing the original |
|
Indeed, this |
|
Concept ACK. If you're willing to entertain paint color requests, I prefer the name |
|
I think @ryanofsky also likes |
|
I think Russ doesn't care about the name, but would prefer a pair of check/dcheck macros: #16136 (comment) |
|
FWIW, libsecp256k1 has CHECK() (always enabled) and VERIFY_CHECK() functions (enabled with -DVERIFY, used in test builds). |
|
Concept ACK |
That is good to know, because that means we can't use that name due to name-clashing. |
|
ACK fa96726: patch looks correct |
Fixes the compile error when used inside operator[]:
./chain.h:404:23: error: C++11 only allows consecutive left square brackets when introducing an attribute
return (*this)[Assert(pindex)->nHeight] == pindex;
^
The TODO has been added by me, but I don't remember how to solve it. The current code works fine, so just remove the TODO.
No
It documents how the |
|
cr ACK faa0585 |
|
utACK faa0585 |
jonatack
left a comment
There was a problem hiding this comment.
Approach ACK, some doc nits if you retouch
| failure, it will throw an exception, which can be caught to recover from the | ||
| error. | ||
| - For example, a nullptr dereference or any other logic bug in RPC code | ||
| means that the RPC code is faulty and can not be executed. However, the |
| behaves like `Assert`/`assert` to notify developers and testers about | ||
| nonfatal errors. In production it doesn't warn or log anything, though the | ||
| expression is always evaluated. | ||
| - For example it can be assumed that a variable is only initialized once, |
There was a problem hiding this comment.
s/For example it can/For example, it may/
|
Will leave style nits alone to preserve ACKs |
|
I think this is ready, but I am waiting on one more (re?)ACK before merge |
faa0585 util: Remove probably misleading TODO (MarcoFalke) fac5efe util: Add Assume() identity function (MarcoFalke) fa86156 util: Allow Assert(...) to be used in all contexts (practicalswift) Pull request description: This is needed for bitcoin#20138. Please refer to the added documentation for motivation. ACKs for top commit: practicalswift: cr ACK faa0585 jnewbery: utACK faa0585 hebasto: ACK faa0585, I have reviewed the code and it looks OK, I agree it can be merged. Tree-SHA512: 72165fbd898b92ab9a79b070993fa1faa86c2e3545b6645e72c652bda295d5107bc298d0482bf3aaf0926fc0c3e6418a445c0e073b08568c44231f547f76a688
Summary: ``` This is needed for #20138. Please refer to the added documentation for motivation. ``` Backport of [[bitcoin/bitcoin#20255 | core#20255]]. Depends on D9681. Comes with a linter fix for an edge case where a macro defining `((void)(val))` would be linted as `(()(val))`. Ref T1611. Test Plan: With and without debug: ninja all check Reviewers: #bitcoin_abc, PiRK Reviewed By: #bitcoin_abc, PiRK Maniphest Tasks: T1611 Differential Revision: https://reviews.bitcoinabc.org/D9680
This is needed for #20138. Please refer to the added documentation for motivation.