Phase 3: -Wcatch-value を潰して -Werror=catch-value を有効化 - #56
Merged
Conversation
thawk105
force-pushed
the
werror-catch-value
branch
from
May 13, 2026 14:23
6cde3fc to
52532e5
Compare
ccbench_add_protocol() に -Werror=catch-value を追加する。
すべて「polymorphic 例外型を value で catch している」典型ケース。
スライシング (catch 時に派生情報が落ちる) を防ぐため const T& に統一する。
真のバグは見つからなかった (Phase 1 の std:: typo のような副次収穫はなし)。
修正パターン (2 種類)
=====================
A. `} catch (bad_alloc) {` → `} catch (const bad_alloc&) {` (44 件)
B. `} catch (std::out_of_range e) {`
→ `} catch (const std::out_of_range& e) {` (2 件)
B は include/bomb.hh:480 と include/bomb_pessimistic.hh:514 の 1 行ずつ
だが、テンプレ展開先で 10 protocol × bomb 系 workload = 11 hit にカウント
されて GCC が同じ行を毎回出力していた。
修正ファイル
============
main() の `bad_alloc` (各 .exe ソース、34 件):
- cc/cicada/{bomb,sbomb,tpcc,ycsb}_cicada.cc:103-114
- cc/d2pl/{dbomb,sbomb}_d2pl.cc:110
- cc/ermia/{bomb,sbomb,tpcc,ycsb}_ermia.cc:103-111
- cc/mocc/{bomb,sbomb,tpcc,ycsb}_mocc.cc:92-101
- cc/mvto/{bomb,tpcc}_mvto.cc:95-103
- cc/oze/{bomb,tpcc,ycsb}_oze.cc:107-120
- cc/si/{bomb,sbomb,tpcc,ycsb}_si.cc:103-111
- cc/silo/{bomb,sbomb,tpcc,ycsb}_silo.cc:121-130
- cc/ss2pl/{bomb,tpcc}_ss2pl.cc:99-118
- cc/tictoc/{bomb,sbomb,tpcc,ycsb}_tictoc.cc:97-106
util.cc の初期化 `bad_alloc` (3 件):
- cc/ermia/util.cc:62
- cc/oze/util.cc:37
- cc/si/util.cc:62
BombWorkload::Query::getRequest の `out_of_range` (2 件):
- include/bomb.hh:480
- include/bomb_pessimistic.hh:514
build に出ていない legacy ファイル (cc/{cicada,ermia,mocc,oze,si,silo,
ss2pl,tictoc}.cc, cc/occ/occ.cc) にも同パターンが残っているが、これらは
ccbench_add_protocol() の SOURCES に登録されておらず CMake target が
ないので今回はスコープ外。
CMake
=====
target_compile_options(${target} PRIVATE
-Werror=maybe-uninitialized
-Werror=unused-but-set-variable
- -Werror=unused-label)
+ -Werror=unused-label
+ -Werror=catch-value)
検証
====
- GCC 13 / Release / -DENABLE_SANITIZER=OFF: 34/34 .exe, catch-value 0
- GCC 11 / Debug+ASan (devcontainer default): 34/34 .exe, catch-value 0
thawk105
force-pushed
the
werror-catch-value
branch
from
May 13, 2026 14:30
52532e5 to
7e544ed
Compare
This was referenced May 13, 2026
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.
#43 Phase 3 のサブタスク。
-Wcatch-valueの 46 件 (ユニーク) を潰し、ccbench_add_protocol()に-Werror=catch-valueを追加する。すべて「polymorphic 例外型を value で catch している」典型ケース。スライシングを防ぐため
const T&に統一した。Phase 1 のような真のバグは含まれていない。修正パターン
} catch (bad_alloc) {} catch (const bad_alloc&) {} catch (std::out_of_range e) {} catch (const std::out_of_range& e) {B はヘッダ 2 か所のみだが、
BombWorkload::Query::getRequestのテンプレ展開で 10 protocols × bomb 系 = 11 件にカウントされていた。修正ファイル
main()のbad_alloc(各.exeソース計 34 件) +util.ccの初期化bad_alloc(3 件) +include/bomb.hh:480+include/bomb_pessimistic.hh:514。合計 39 ファイル。build に出ていない legacy ファイル (
cc/{cicada,ermia,mocc,…}.cc,cc/occ/occ.cc) にも同パターンが残っているが、これらはccbench_add_protocol()の SOURCES に未登録で CMake target がないためスコープ外。CMake
target_compile_options(${target} PRIVATE -Werror=maybe-uninitialized -Werror=unused-but-set-variable - -Werror=unused-label) + -Werror=unused-label + -Werror=catch-value)Test plan
-DENABLE_SANITIZER=OFF: 34/34.exe、catch-value 0.exe、catch-value 0Related