Skip to content

Phase 5: set_compile_options() で -Wall -Wextra -Werror を有効化 (#43)#80

Merged
thawk105 merged 2 commits into
masterfrom
werror-phase5-finalize
May 14, 2026
Merged

Phase 5: set_compile_options() で -Wall -Wextra -Werror を有効化 (#43)#80
thawk105 merged 2 commits into
masterfrom
werror-phase5-finalize

Conversation

@thawk105
Copy link
Copy Markdown
Owner

概要

issue #43 の段階的 -Werror 化、最終フェーズ (Phase 5 = 仕上げ)。Phase 1〜4 で 9 個の -Werror=<flag> クラスを 1 つずつ潰してきたが、Phase 5 ではその明示リストを set_compile_options() (= -Wall -Wextra -Werror) に置き換える。

cmake 変更

  • cmake/ProtocolHelpers.cmake: ccbench_add_protocol() 内の target_compile_options(... -Werror=... ) 9 個の列を set_compile_options(${target}) 呼び出しに置き換え。
  • CMakeLists.txt: set_compile_options() を使えるよう include(CompileOptions) を冒頭に hoist し、ccbench_common ターゲットにも適用。
  • cc/silo/CMakeLists.txt: スタンドアロンの replay_test.exe にも適用。

set_compile_options() が有効化するのは -Wall -Wextra -Werror の 3 つだけ (cmake/CompileOptions.cmake)。-Wpedantic / -Wshadow / -Wconversion 等は含まない。

新規 warning と対処

-Wall -Wextraccbench_common と全プロトコルバイナリに適用したことで、Phase 1〜4 で潰した 9 クラス以外に 3 クラスが表面化した。いずれも小規模・機械的なので本 PR 内で対処:

ファイル warning 対処
common/result.cc -Wunused-parameter (3 件) displayOzeAnalysisResult() の引数は #if ADD_ANALYSIS 時のみ使用 → 直下の displayAllResult() と同じく [[maybe_unused]] を付与
cc/silo/include/log.hh -Wclass-memaccess (2 箇所) LogRecordstd::string_view を持つ非 trivial 型。computeChkSum() のため padding 含め全バイトゼロ化する意図は正しいので、memsetstatic_cast<void *>(this) 経由に変更
include/tpcc/tpcc_util.hh -Wstringop-overflow (26 件) GCC 13 が fill_random()random_string_detail() にインライン展開した際の interprocedural な誤検知。ループは size >= 8 の間しか回らず、呼び出し側は常に max_len + 1 バイトのバッファを渡すため overflow しない。ホットな init パスを悪化させず、説明コメント付きで局所的に suppress

test plan

GCC 13 (= CI と同じコンパイラ) でクリーンフルビルド:

cmake -B build -DCMAKE_BUILD_TYPE=Release -DENABLE_SANITIZER=OFF \
  -DCMAKE_CXX_COMPILER=g++-13 -DCMAKE_C_COMPILER=gcc-13 .
cmake --build build -j4

結果: exit 0 / warning 0 / error 0。全 34 プロトコルバイナリ + ccbench_common + replay_test.exe がビルド成功。

Closes #43

thawk105 added 2 commits May 14, 2026 07:37
Phases 1-4 promoted nine -Werror=<flag> classes one at a time as the
existing offenders got fixed. Phase 5 replaces that explicit list with
the full -Wall -Wextra -Werror:

- cmake/ProtocolHelpers.cmake: ccbench_add_protocol() now calls
  set_compile_options(${target}) instead of the 9-entry
  target_compile_options(... -Werror=...) list.
- CMakeLists.txt: include(CompileOptions) hoisted to the top so
  set_compile_options() is available, and applied to ccbench_common.
- cc/silo/CMakeLists.txt: applied to the standalone replay_test.exe.
…#43)

Enabling -Wall -Wextra -Werror on ccbench_common and the protocol
binaries surfaced three warning classes beyond the nine already cleaned
in Phases 1-4:

- common/result.cc: displayOzeAnalysisResult()'s parameters are only
  used under #if ADD_ANALYSIS — mark them [[maybe_unused]], matching
  displayAllResult() right below (-Wunused-parameter).
- cc/silo/include/log.hh: LogRecord is non-trivial (holds a
  std::string_view), so memset(this, ...) trips -Wclass-memaccess.
  Zeroing every byte (incl. padding) is intentional for computeChkSum(),
  so route the memset through static_cast<void *>(this).
- include/tpcc/tpcc_util.hh: GCC 13's interprocedural -Wstringop-overflow
  false-positives on fill_random()'s word-at-a-time loop when inlined
  into random_string_detail() for the 51-byte I_DATA / S_DATA buffers.
  The loop only runs while size >= 8 and callers always pass max_len + 1
  bytes, so suppress -Wstringop-overflow locally with an explanatory
  comment rather than pessimizing the hot init path.
@thawk105 thawk105 merged commit 27ac20e into master May 14, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

段階的に -Werror 化してビルドを堅牢にする

1 participant