You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
TASK-060: scope or remove file-scoped -Warray-bounds suppressions
Eliminate both unscoped `#pragma GCC diagnostic ignored "-Warray-bounds"`
directives flagged in specs/tasks/v2-branch-gap-audit.md §1 and add a
lint-lane gate that prevents either watched file from regaining a
file-scoped suppression.
Site A — src/http_utils.cpp:62
The pragma sat above three orphan macros (CHECK_BIT, SET_BIT,
CLEAR_BIT). Those macros had no remaining call sites in this TU after
commit 7fc443a extracted the ip_representation body to
src/detail/ip_representation.cpp; the pragma was guarding nothing.
Delete both the pragma and the orphan macros.
Site B — src/detail/ip_representation.cpp:55
The pragma sat above two used macros (CHECK_BIT, CLEAR_BIT) with five
call sites. The historic -Warray-bounds false positive on these
function-like macro shapes is the standard GCC VRP-loses-bound-across-
macro-expansion pattern: at the call site `mask &= ~(1 << pos)` the
value-range propagator can't see the loop-derived `[0, 15]` bound on
`pos` and speculates a shift outside the storage GCC infers for the
`uint16_t mask`.
Replace both macros with anonymous-namespace `constexpr` helpers that
take `pos` as `unsigned int` and force the shift through `1u`, with
the bitwise-and-assign going through an explicit
`static_cast<uint16_t>`. The function-call boundary plus explicit
unsigned types is the documented recipe that silences the warning at
the source on every supported GCC, so the file-scoped suppression
can go away with no scoped push/pop fallback. All five call sites
mechanically swap to the helper and explicitly cast their signed
index expressions to `unsigned int` to keep the conversion visible.
Guard — scripts/check-warning-suppressions.sh (new)
Bash script wired into Makefile.am as `lint-warning-suppressions` and
into the verify-build.yml lint lane next to lint-file-size /
lint-complexity. For each watched file, it greps for top-of-line
`#pragma GCC diagnostic ignored "-Warray-bounds"` and fails unless
each hit is bracketed by an earlier `#pragma GCC diagnostic push` and
a later `pop`. Watched-file list is intentionally narrow to the two
TASK-060 files; future tasks broaden it as new suppressions are
scoped.
Acceptance criteria:
- `grep -nE '^#pragma GCC diagnostic ignored "-Warray-bounds"'
src/http_utils.cpp src/detail/ip_representation.cpp` returns no
matches.
- Debug build (`--enable-debug`, -Werror -Wall -Wextra -pedantic) on
macOS Apple-Clang succeeds with no new warnings.
- http_utils unit suite (412 checks across 87 tests, exercises
ip_representation parsing) passes; ban_system integ suite passes
in isolation, exercising block_ip / unblock_ip which round-trip
through both rewritten helpers.
- CI's GCC 11/12/13/14 matrix lanes will surface any residual
-Warray-bounds regression by failing the compile.
GCC-version diagnostic capture deferred to CI — the local host is
Apple Clang and has no GCC. If a CI lane still emits the warning after
the rewrite, the documented fallback (scoped push/pop with a
__GNUC__-conditional version guard) lands in a follow-up commit on
this branch.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
0 commit comments