Warning cleanup: baseline with -Wall/-Wextra, drive to zero, then consider -Werror #7

Open
opened 2026-11-29 00:14:32 +00:00 by opencode · 1 comment
Owner

Context

~400k LOC of pre-2021 C++ built by three different toolchains. No -Wall/-Wextra baseline exists; warnings are unknown/untracked. The new CI should not fail on warnings yet (-Werror is premature), but the signal must be visible and shrinking.

What to do

  1. Add -Wall -Wextra (GCC/Clang) to the CMake build (option or default), produce a categorized count (by warning type × file).
  2. Fix the cheap, high-signal classes first (missing includes are already tracked separately; then things like -Wclass-memaccess, sign-compare in engine-adjacent code, unused variables in extras/).
  3. Track the count in CI (print a summary line per build; optionally a workflow step that fails only if the count GROWS vs. a committed baseline number).
  4. Only once the count is near-zero on both branches, propose -Werror for CI.

Acceptance

  • Warning count visible in every CI run.
  • Monotonically decreasing across the milestone; baseline number committed to the repo.
  • No behavior changes: warning fixes must not alter game logic (prefer casts/guards that are provably no-ops).
## Context ~400k LOC of pre-2021 C++ built by three different toolchains. No `-Wall`/`-Wextra` baseline exists; warnings are unknown/untracked. The new CI should not fail on warnings yet (`-Werror` is premature), but the signal must be visible and shrinking. ## What to do 1. Add `-Wall -Wextra` (GCC/Clang) to the CMake build (option or default), produce a categorized count (by warning type × file). 2. Fix the cheap, high-signal classes first (missing includes are already tracked separately; then things like `-Wclass-memaccess`, sign-compare in engine-adjacent code, unused variables in `extras/`). 3. Track the count in CI (print a summary line per build; optionally a workflow step that fails only if the count GROWS vs. a committed baseline number). 4. Only once the count is near-zero on both branches, propose `-Werror` for CI. ## Acceptance - Warning count visible in every CI run. - Monotonically decreasing across the milestone; baseline number committed to the repo. - No behavior changes: warning fixes must not alter game logic (prefer casts/guards that are provably no-ops).
opencode added this to the M4: Toolchain & language modernization milestone 2026-11-29 00:14:32 +00:00
opencode added the cimodernization labels 2026-11-29 00:14:32 +00:00
Author
Owner

Measured baseline (GCC 13.3, RelWithDebInfo, master @ 5c86592e):

  • 10,878 warnings + 510 notes: 6,723 in src/, 4,152 in vendor/librw; 28 distinct -W flags active.

Top flags: unused-parameter 5224 · pedantic 1950 · unknown-pragmas 895 · strict-aliasing 786 · parentheses 463 · ignored-qualifiers 444 · sign-compare 241 · double-promotion 157 · maybe-uninitialized 134 · stringop-truncation 50 · deprecated-copy 37 · class-memaccess 34.

Highest-risk class: -Wmaybe-uninitialized (134) — real-bug-adjacent. Biggest single cluster: the src/control/Script*.cpp family (Script4 203, Script3 196, Script2 129, Script5 108, Script 98, Script6 89 ≈ 823 total). Headers dominate per-location counts (vendor/librw/src/rwbase.h 2008, src/core/common.h 1790, src/vehicles/Vehicle.h 1472).

Suggested first milestones: (1) fix all maybe-uninitialized; (2) burn down the Script*.cpp cluster; (3) decide whether -Wpedantic noise (anonymous structs — a deliberate R* idiom) gets suppressed project-wide rather than fixed.

**Measured baseline (GCC 13.3, RelWithDebInfo, master @ 5c86592e):** - **10,878 warnings** + 510 notes: 6,723 in `src/`, 4,152 in `vendor/librw`; 28 distinct `-W` flags active. Top flags: `unused-parameter` 5224 · `pedantic` 1950 · `unknown-pragmas` 895 · `strict-aliasing` 786 · `parentheses` 463 · `ignored-qualifiers` 444 · `sign-compare` 241 · `double-promotion` 157 · **`maybe-uninitialized` 134** · `stringop-truncation` 50 · `deprecated-copy` 37 · `class-memaccess` 34. Highest-risk class: `-Wmaybe-uninitialized` (134) — real-bug-adjacent. Biggest single cluster: the `src/control/Script*.cpp` family (Script4 203, Script3 196, Script2 129, Script5 108, Script 98, Script6 89 ≈ 823 total). Headers dominate per-location counts (`vendor/librw/src/rwbase.h` 2008, `src/core/common.h` 1790, `src/vehicles/Vehicle.h` 1472). Suggested first milestones: (1) fix all `maybe-uninitialized`; (2) burn down the Script*.cpp cluster; (3) decide whether `-Wpedantic` noise (anonymous structs — a deliberate R* idiom) gets suppressed project-wide rather than fixed.
Sign in to join this conversation.