clang-tidy: resolve bugprone-implicit-widening-of-multiplication-result#496
Conversation
There was a problem hiding this comment.
Pull request overview
This PR addresses clang-tidy’s bugprone-implicit-widening-of-multiplication-result findings by making std::size_t-typed expectations explicit in several tests (plus one compile-time array extent), and updates the April 2026 clang-tidy fixes tracking doc accordingly.
Changes:
- Updated several
CHECK(g.execution_count(...) == ...)expectations to convert products tostd::size_t. - Adjusted a
std::arrayextent expression in the giantdata demo to use unsigned-long-long literals. - Marked
bugprone-implicit-widening-of-multiplication-resultas complete indocs/dev/clang-tidy-fixes-2026-04.md.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| test/hierarchical_nodes.cpp | Casts multiplication result used in execution-count expectations to std::size_t. |
| test/fold.cpp | Casts multiplication result used in execution-count expectations to std::size_t. |
| test/different_hierarchies.cpp | Casts one execution-count product expectation to std::size_t. |
| test/demo-giantdata/waveforms.hpp | Changes std::array extent to use ull literals in the multiplication. |
| test/cached_execution.cpp | Casts multi-factor execution-count expectations to std::size_t. |
| docs/dev/clang-tidy-fixes-2026-04.md | Checks off the clang-tidy item for this warning class. |
Codecov Report✅ All modified and coverable lines are covered by tests. @@ Coverage Diff @@
## main #496 +/- ##
==========================================
- Coverage 85.57% 85.54% -0.03%
==========================================
Files 142 142
Lines 3604 3604
Branches 616 616
==========================================
- Hits 3084 3083 -1
Misses 310 310
- Partials 210 211 +1
Flags with carried forward coverage won't be shown. Click here to find out more. Continue to review full report in Codecov by Sentry.
🚀 New features to boost your workflow:
|
knoepfel
left a comment
There was a problem hiding this comment.
Thanks, @greenc-FNAL. A couple questions below.
|
|
||
| CHECK(g.execution_count("B1") == n_runs * n_subruns); | ||
| CHECK(g.execution_count("B2") == n_runs * n_subruns); | ||
| CHECK(g.execution_count("B1") == std::size_t{n_runs} * n_subruns); |
There was a problem hiding this comment.
I wonder if a large swath of these warnings can be fixed by just changing the type of (e.g.) n_runs to std::size_t.
There was a problem hiding this comment.
That would probably work, but in general I was trying to avoid semantic changes to the tests wherever possible. Let me know if you'd like me to go ahead and make this change.
There was a problem hiding this comment.
Understood. I think this is an example where clang-tidy identified a potential problem, and the cleanest solution is to adjust the type of n_runs, etc.
…esult` Some tests multiply integer constants or variables in contexts where the result is expected to be `std::size_t`: we resolve the check complaints by explicitly converting to `std::size_t`.
…sult after; add PR link to docs Agent-Logs-Url: https://github.com/Framework-R-D/phlex/sessions/75b911b7-81ef-400f-bbd6-f641fb353276 Co-authored-by: greenc-FNAL <2372949+greenc-FNAL@users.noreply.github.com>
59eeffc to
1e13c21
Compare
The tests have failed, likely due to a mismatch in types.
|
@knoepfel Should I revert? |
Yes, let's revert those changes for now. |
Type change propagates to persistent types, causing test failures: too many changes required. This reverts commit d194b63.
Multiplications in test assertions and a compile-time array extent were done in
unsigned intbefore widening tostd::size_t. Cast one operand before multiplying so arithmetic happens in the correct type throughout.Before:
After:
test/hierarchical_nodes.cpp,test/fold.cpp,test/different_hierarchies.cpp,test/cached_execution.cpp: Replacestd::size_t(a * b)withstd::size_t{a} * binexecution_countassertions.test/demo-giantdata/waveforms.hpp: Replace3ull * 1024ullarray extent withstd::size_t{3} * 1024.docs/dev/clang-tidy-fixes-2026-04.md: Mark check as resolved and link this PR, consistent with other completed entries.