Skip to content

Conversation

@Abhi10111
Copy link

@Abhi10111 Abhi10111 commented Jan 7, 2026

Problem:
ASSERT_FALSE negates the expression before passing it to AssertionResult,
which forces early boolean conversion and bypasses the
AssertionResult(const T&) constructor. This leads to inconsistent overload
resolution compared to ASSERT_TRUE when types define both const and
non-const operator bool().

Solution:
Both ASSERT_TRUE and ASSERT_FALSE now pass the original expression to
AssertionResult, allowing const-correct evaluation. The expected boolean
value is compared after AssertionResult construction, restoring symmetric
behavior.

Tests:
Added a regression test demonstrating the inconsistency with a type that
defines both const and non-const operator bool(). The test fails on main
and passes with this change.

Fixes #4832

…ead to differing failure results"

Signed-off-by: Abhi10111 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: ASSERT_FALSE and ASSERT_TRUE const propagation inconsistencies lead to differing failure results

1 participant