-
Notifications
You must be signed in to change notification settings - Fork 37.7k
util: Add Assume() identity function #20255
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK fa96726
I think this is a good choice of behaviour that should be easy to use correctly. Would like to see the ability to turn on logging of violated Assumptions even in production builds in a followup.
ACK fa96726: patch looks correct |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approach ACK fa96726
Are there any cases when assert
is preferable to Assert
. If "yes", it would be nice to have an example in the docs. If "no", why do we mention assert
in the docs?
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/can not/cannot/
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK faa0585, I have reviewed the code and it looks OK, I agree it can be merged.
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.