Phase 5: set_compile_options() で -Wall -Wextra -Werror を有効化 (#43)#80
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
概要
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 -Wextraをccbench_commonと全プロトコルバイナリに適用したことで、Phase 1〜4 で潰した 9 クラス以外に 3 クラスが表面化した。いずれも小規模・機械的なので本 PR 内で対処:common/result.cc-Wunused-parameter(3 件)displayOzeAnalysisResult()の引数は#if ADD_ANALYSIS時のみ使用 → 直下のdisplayAllResult()と同じく[[maybe_unused]]を付与cc/silo/include/log.hh-Wclass-memaccess(2 箇所)LogRecordはstd::string_viewを持つ非 trivial 型。computeChkSum()のため padding 含め全バイトゼロ化する意図は正しいので、memsetをstatic_cast<void *>(this)経由に変更include/tpcc/tpcc_util.hh-Wstringop-overflow(26 件)fill_random()をrandom_string_detail()にインライン展開した際の interprocedural な誤検知。ループはsize >= 8の間しか回らず、呼び出し側は常にmax_len + 1バイトのバッファを渡すため overflow しない。ホットな init パスを悪化させず、説明コメント付きで局所的に suppresstest plan
GCC 13 (= CI と同じコンパイラ) でクリーンフルビルド:
結果: exit 0 / warning 0 / error 0。全 34 プロトコルバイナリ +
ccbench_common+replay_test.exeがビルド成功。Closes #43