Skip to content

[ML] Fix compiler warnings across the codebase#2985

Draft
edsavage wants to merge 5 commits intoelastic:mainfrom
edsavage:fix/compiler-warnings
Draft

[ML] Fix compiler warnings across the codebase#2985
edsavage wants to merge 5 commits intoelastic:mainfrom
edsavage:fix/compiler-warnings

Conversation

@edsavage
Copy link
Contributor

Summary

  • Reduces Clang warnings from ~2,500 to 86 (all remaining are -Wunsafe-buffer-usage, which require a std::span migration and are out of scope here).
  • Adds three warning suppressions to clang.cmake:
    • -Wno-switch-default (174 warnings) — conflicts with the more useful -Wswitch-enum; adding default: to exhaustive enum switches would suppress missing-case detection when new enum values are added.
    • -Wno-nrvo (19 warnings) — purely informational C++23 diagnostic about NRVO eligibility.
    • -Wno-missing-noreturn (5 warnings) — all remaining cases are lambdas where [[noreturn]] cannot be applied pre-C++23.
  • Fixes 80 code warnings across 59 files:
    • Removes 37 unused const variables (dead code from state serialisation refactors).
    • Removes 2 unused functions (calibrationExperiment, dataGenerator in tests) and 2 unused-but-set variables.
    • Fixes 9 shadow warnings by renaming inner variables.
    • Fixes 8 implicit int-to-float conversions with explicit static_cast<double>().
    • Fixes 2 tautological-compare logic bugs where !(p >= 0.0 || p <= 1.0) was always false — corrected to !(p >= 0.0 && p <= 1.0).
    • Removes 2 redundant default: cases in exhaustive enum switches.
    • Fixes 1 pessimizing-move, 1 range-loop-bind-reference, 1 sign-compare, 1 shorten-64-to-32, 1 CTAD issue.
    • Removes unnecessary virtual from method in final class.
    • Adds [[noreturn]] to named function throws().

Test plan

  • CI passes on all platforms (Linux x86_64, Linux aarch64, macOS aarch64, Windows x86_64)
  • clang-format check passes
  • Verify no behavioural changes other than the tautological-compare bug fixes

Made with Cursor

Reduce Clang warnings from ~2500 to 86 (all remaining are
-Wunsafe-buffer-usage which require a std::span migration).

Compiler flag suppressions (clang.cmake):
- -Wno-switch-default: conflicts with the more useful -Wswitch-enum
- -Wno-nrvo: purely informational C++23 diagnostic
- -Wno-missing-noreturn: remaining cases are lambdas where
  [[noreturn]] cannot be applied pre-C++23

Code fixes across 59 files:
- Remove 37 unused const variables (dead code from state
  serialisation refactors)
- Remove 2 unused functions and 2 unused-but-set variables
- Fix 9 shadow warnings by renaming inner variables
- Fix 8 implicit int-to-float conversions with static_cast
- Fix 2 tautological-compare logic bugs where the condition
  !(p >= 0.0 || p <= 1.0) was always false
- Remove 2 redundant default cases in exhaustive enum switches
- Fix 1 pessimizing-move, 1 range-loop-bind-reference,
  1 sign-compare, 1 shorten-64-to-32, 1 CTAD issue
- Remove unnecessary virtual from method in final class
- Add [[noreturn]] to named function throws()
- Add missing newline at EOF

Made-with: Cursor
@prodsecmachine
Copy link

prodsecmachine commented Mar 12, 2026

Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues
Licenses 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

Made-with: Cursor

# Conflicts:
#	bin/pytorch_inference/Main.cc
Change [=] to [this, f] in CConcurrentWrapper to silence
-Wdeprecated on GCC 13 and Clang.

Made-with: Cursor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants