Skip to content
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

CHECK() and REQUIRE() evaluate the expression operands twice #13

Closed
cschreib opened this issue Oct 30, 2022 · 0 comments · Fixed by #15
Closed

CHECK() and REQUIRE() evaluate the expression operands twice #13

cschreib opened this issue Oct 30, 2022 · 0 comments · Fixed by #15
Labels
bug:confirmed Something isn't working (confirmed)

Comments

@cschreib
Copy link
Member

cschreib commented Oct 30, 2022

Currently, the check macros evaluate the expression operands twice: once in the if for the check, and again later when building the expression string (but only if the check fails). This could be costly if one of the operands is expensive to evaluate, such as std::accumulate(...). It could also lead to bugs or surprising results if the operand evaluation has side effects.

@cschreib cschreib added the bug:unconfirmed Something isn't working (to be confirmed) label Oct 30, 2022
@cschreib cschreib added bug:confirmed Something isn't working (confirmed) and removed bug:unconfirmed Something isn't working (to be confirmed) labels May 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug:confirmed Something isn't working (confirmed)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant