The handler macros trip -Wimplicit-fallthrough, so consumers cannot adopt -Wextra #18

Open
opened 2026-08-02 21:53:13 -04:00 by tachikoma · 0 comments
Collaborator

Source: found sweeping consumer repositories for stale TODO.md references; recorded in libakgl and never here

PROCESS, HANDLE and HANDLE_GROUP expand into switch arms that fall through between
case labels by design — that is how a handler chain reaches the next arm. GCC's
-Wimplicit-fallthrough, which -Wextra turns on, cannot tell that apart from the mistake it
exists to catch.

The cost is measured, in a consumer. libakgl evaluated -Wextra and declined it:

4 -Wimplicit-fallthrough from libakerror's own PROCESS/HANDLE/HANDLE_GROUP, which
fall through between case labels by design. Adopting it today would mean disabling both
permanently to gain 5 -Wsign-compare.

So a consumer's choice is to build without -Wextra, or to turn the warning off globally and
lose it everywhere in its own code. Both are worse than the macro saying what it means.

The fix is one statement per arm. C23 spells it [[fallthrough]];; GCC and clang have
understood __attribute__((fallthrough)) for far longer, and a comment matching
-Wimplicit-fallthrough's default regex (/* fall through */) works on GCC alone. A macro
that picks per compiler — AKERR_FALLTHROUGH — keeps it in one place and costs nothing where
the attribute is unavailable.

Verify it the way the cost was measured: build libakgl with -Wextra and count. Four
warnings should become zero, and its CMakeLists.txt comment explaining why -Wextra is off
should be deletable in the same change.

This is the fourth defect in this library found written down in a consumer rather than here.
The other three are #14, #15 and #16.


Filed by Tachikoma (Claude Code, Opus 5, 1M context)

**Source:** found sweeping consumer repositories for stale `TODO.md` references; recorded in `libakgl` and never here `PROCESS`, `HANDLE` and `HANDLE_GROUP` expand into `switch` arms that fall through between `case` labels **by design** — that is how a handler chain reaches the next arm. GCC's `-Wimplicit-fallthrough`, which `-Wextra` turns on, cannot tell that apart from the mistake it exists to catch. **The cost is measured, in a consumer.** `libakgl` evaluated `-Wextra` and declined it: > 4 `-Wimplicit-fallthrough` from libakerror's own `PROCESS`/`HANDLE`/`HANDLE_GROUP`, which > fall through between `case` labels by design. Adopting it today would mean disabling both > permanently to gain 5 `-Wsign-compare`. So a consumer's choice is to build without `-Wextra`, or to turn the warning off globally and lose it everywhere in its *own* code. Both are worse than the macro saying what it means. **The fix is one statement per arm.** C23 spells it `[[fallthrough]];`; GCC and clang have understood `__attribute__((fallthrough))` for far longer, and a comment matching `-Wimplicit-fallthrough`'s default regex (`/* fall through */`) works on GCC alone. A macro that picks per compiler — `AKERR_FALLTHROUGH` — keeps it in one place and costs nothing where the attribute is unavailable. **Verify it the way the cost was measured:** build `libakgl` with `-Wextra` and count. Four warnings should become zero, and its `CMakeLists.txt` comment explaining why `-Wextra` is off should be deletable in the same change. This is the fourth defect in this library found written down in a consumer rather than here. The other three are #14, #15 and #16. --- Filed by Tachikoma (Claude Code, Opus 5, 1M context)
tachikoma added this to the 2.0.x milestone 2026-08-02 21:53:13 -04:00
tachikoma added the defectpackagingblast-radius:mediumstatus::grooming labels 2026-08-02 21:53:13 -04:00
Sign in to join this conversation.