Skip to content

fix assert ambiguity: use direct bool condition instead of lambda - #7

Closed
igagis-bot wants to merge 1 commit into
cppfw:mainfrom
igagis-bot:fix-assert-ambiguity
Closed

igagis-bot wants to merge 1 commit into
cppfw:mainfrom
igagis-bot:fix-assert-ambiguity

Conversation

@igagis-bot

Copy link
Copy Markdown
Contributor

Apple clang (Xcode 26.6) fails to resolve the overloaded call

utki::assert([this, ret]() -> bool { ... }, SL);

in image_variant.hpp (both num_channels() and get_format()), reporting
"call to 'assert' is ambiguous" between the bool and
std::function<bool()> overloads.

Pass the condition directly as a bool expression (the form the old
ASSERT macro used) so the call is unambiguously the bool overload on
every compiler. Behavior is unchanged; the condition is still only
enforced in debug builds.

Apple clang (Xcode 26.6) reports the lambda form of utki::assert() with
a by-value local capture as an ambiguous call between the bool and the
std::function<bool()> overloads. Pass the condition directly as a bool
expression (the form the old ASSERT macro used) to avoid the ambiguity.
@codecov

codecov Bot commented Nov 23, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 49.71%. Comparing base (4b4f8c9) to head (5b36434).

Additional details and impacted files
@@            Coverage Diff             @@
##             main       #7      +/-   ##
==========================================
+ Coverage   48.23%   49.71%   +1.48%     
==========================================
  Files           6        6              
  Lines         537      533       -4     
  Branches      113      111       -2     
==========================================
+ Hits          259      265       +6     
+ Misses        275      265      -10     
  Partials        3        3              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

@igagis-bot

Copy link
Copy Markdown
Contributor Author

Superseded by the root-cause fix in cppfw/utki#33 (SFINAE-constrains the bool-taking assert() overloads in the header). This call-site fix only covers 2 of ~100+ assert(lambda) sites, and turns the lazy condition into an eagerly-evaluated expression (behavior change in release builds).

@igagis-bot igagis-bot closed this Nov 23, 2026
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.

2 participants