mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-04-29 14:59:39 -04:00
Merge bitcoin/bitcoin#32100: doc: clarify the documentation of Assume
assertion
Some checks are pending
CI / test each commit (push) Waiting to run
CI / macOS 14 native, arm64, no depends, sqlite only, gui (push) Waiting to run
CI / macOS 14 native, arm64, fuzz (push) Waiting to run
CI / Win64 native, VS 2022 (push) Waiting to run
CI / Win64 native fuzz, VS 2022 (push) Waiting to run
CI / ASan + LSan + UBSan + integer, no depends, USDT (push) Waiting to run
Some checks are pending
CI / test each commit (push) Waiting to run
CI / macOS 14 native, arm64, no depends, sqlite only, gui (push) Waiting to run
CI / macOS 14 native, arm64, fuzz (push) Waiting to run
CI / Win64 native, VS 2022 (push) Waiting to run
CI / Win64 native fuzz, VS 2022 (push) Waiting to run
CI / ASan + LSan + UBSan + integer, no depends, USDT (push) Waiting to run
329a0dcdaf
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 https://github.com/bitcoin/bitcoin/pull/31363#issuecomment-2736410023. ACKs for top commit: l0rinc: ACK329a0dcdaf
hodlinator: re-ACK329a0dcdaf
jonatack: ACK329a0dcdaf
rkrux: re-ACK329a0dcdaf
Tree-SHA512: 4bbb807a1e632694863c1a1fa2e93cc5a756b19f8d78f0642ebe7ffafb01835765fa66c76a680dc6f3c412a5abb0c4a33fb7212c26b4b2d80b6b3b7ee8284b2e
This commit is contained in:
commit
a54baa8698
1 changed files with 4 additions and 1 deletions
|
@ -460,7 +460,10 @@ other input.
|
|||
safely continue even if the assumption is violated. In debug builds it
|
||||
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.
|
||||
expression is always evaluated. However, if the compiler can prove that
|
||||
an expression inside `Assume` is side-effect-free, it may optimize the call away,
|
||||
skipping its evaluation in production. This enables a lower-cost way of
|
||||
making explicit statements about the code, aiding review.
|
||||
- For example it can be assumed that a variable is only initialized once,
|
||||
but a failed assumption does not result in a fatal bug. A failed
|
||||
assumption may or may not result in a slightly degraded user experience,
|
||||
|
|
Loading…
Add table
Reference in a new issue