Skip to content

Commit a54baa8

Browse files
committed
Merge bitcoin/bitcoin#32100: doc: clarify the documentation of Assume assertion
329a0dc doc: clarify the documentation of `Assume` (ismaelsadeeq) Pull request description: An Expression inside `Assume` may be optimized away in production builds when the compiler proves they are side-effect-free. This use case is demonstrated in #31363 and is suggested to be documented in bitcoin/bitcoin#31363 (comment). ACKs for top commit: l0rinc: ACK 329a0dc hodlinator: re-ACK 329a0dc jonatack: ACK 329a0dc rkrux: re-ACK 329a0dc Tree-SHA512: 4bbb807a1e632694863c1a1fa2e93cc5a756b19f8d78f0642ebe7ffafb01835765fa66c76a680dc6f3c412a5abb0c4a33fb7212c26b4b2d80b6b3b7ee8284b2e
2 parents b131e1b + 329a0dc commit a54baa8

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

doc/developer-notes.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,10 @@ other input.
460460
safely continue even if the assumption is violated. In debug builds it
461461
behaves like `Assert`/`assert` to notify developers and testers about
462462
nonfatal errors. In production it doesn't warn or log anything, though the
463-
expression is always evaluated.
463+
expression is always evaluated. However, if the compiler can prove that
464+
an expression inside `Assume` is side-effect-free, it may optimize the call away,
465+
skipping its evaluation in production. This enables a lower-cost way of
466+
making explicit statements about the code, aiding review.
464467
- For example it can be assumed that a variable is only initialized once,
465468
but a failed assumption does not result in a fatal bug. A failed
466469
assumption may or may not result in a slightly degraded user experience,

0 commit comments

Comments
 (0)