#36275 build: enable `-Wunused-const-variable`

full analysis

https://github.com/bitcoin/bitcoin/pull/36275 · fanquake · +31/-27 in 10 files, 5 commits · labels: Build system, CI failed · draft

Goal

  • Catch unused constant definitions in headers automatically with a dedicated compiler warning
  • Prevents dead code clutter and unneeded static variables across compilation units

Enables the `-Wunused-const-variable` compiler flag in CMake. To satisfy the new warning, it updates constant definitions across project headers and vendored subtrees (leveldb, minisketch, crc32c) to use `inline constexpr`.

Problem: Unused constants in header files can persist unnoticed, cluttering code and producing unneeded static variables across compilation units without compiler diagnostics.

Category: Build and CI (#37 of 55)

P3 · cleanup

  • P3 because it improves developer hygiene by flagging dead constant definitions in headers
  • Helps incrementally unblock enabling broader unused compiler warnings across the codebase

Enabling compiler warnings improves developer hygiene and prevents dead constant definitions in headers. As noted by the author, this was split out of #36167 to incrementally enable `-Wunused`.

Membership: Touches CMakeLists.txt to add the `-Wunused-const-variable` compiler warning flag.

Factors: security/stability 0, bug 0, performance 0, user value 0, leverage 1

Reviewability: Paused: Review subtrees first

  • Review upstream subtree PRs in leveldb, minisketch, and crc32c first
  • Author is waiting for subtree changes to merge and flagged the commits as nomerge

The author explicitly requested reviewing external subtree PRs (leveldb #65, minisketch #105, crc32c #10) first, and the corresponding subtree commits are flagged as nomerge.

Author status: Waiting for upstream subtree PRs to be reviewed and merged.

Agreement: Crickets

  • No reviews or feedback yet
  • Recently opened as a draft waiting on upstream subtree updates

No reviews or comments yet.

The pull request was recently opened as a draft and has had no reviewer interaction.

Review verdicts (DrahtBot): 0

Dependencies

Enables:

Files

0 lines under test/bench/ci.

  • src/leveldb/db/dbformat.h +8/-8
  • src/logging.h +5/-5
  • src/policy/fees/mempool_estimator.h +4/-4
  • src/leveldb/db/log_format.h +3/-3
  • src/minisketch/src/lintrans.h +4/-1
  • src/leveldb/include/leveldb/db.h +2/-2
  • src/leveldb/table/format.h +2/-2
  • src/crc32c/src/crc32c_internal.h +1/-1
  • src/leveldb/util/crc32c.h +1/-1
  • CMakeLists.txt +1/-0

Card

Enables the -Wunused-const-variable compiler warning flag in CMake and marks existing header constants in logging, mempool estimation, and subtrees as inline constexpr. This prevents dead constants from accumulating silently and unblocks the broader -Wunused effort in #36167. Review is paused while external subtree PRs (leveldb, minisketch, crc32c) are reviewed first.

Data

dossier JSON · extract JSON · model openrouter/google/gemini-3.8-flash, generated 2026-09-17T15:59, confidence high, input hash 654e7cc82003f8f0