Phase 1: -Wunused-label を潰して -Werror=unused-label を有効化 (Phase 1 完了)#50
Merged
Conversation
…error=unused-label #43 Phase 1 の最後。-Wunused-label の 7 件を潰し、ccbench_add_protocol() に -Werror=unused-label を追加する。Phase 1 これで完了。 うち 6 件は dead label の整理、1 件は std:: typo の真のバグ修正。 Dead labels (6 件) ================== 複数の関数で同名の FINISH_* ラベルが定義されていて、片方の関数では goto で 使われているが、もう片方では goto 参照が一切ない。各 warning 位置の囲み 関数を確認した上で、その関数内で実際に未使用のもののみ削除。同名でも別 関数の現役 goto target は触らない。 - cc/d2pl/transaction.cc:172 FINISH_READ in read_internal - cc/mocc/transaction.cc:487 FINISH_DELETE in delete_record - cc/mvto/transaction.cc:224 FINISH_DELETE in delete_record - cc/oze/transaction.cc:823 FINISH_VALIDATION in write_validation - cc/oze/transaction.cc:1001 FINISH_VALIDATION in read_validation - cc/tictoc/transaction.cc:165 FINISH_READ in read_internal これらは概ね「関数末尾で `LABEL: <ADD_ANALYSIS の計測コード>; return ...;` の 形」をしていた。ラベル経由の遷移は無く、通常の制御フローでそこに到達して いたので、ラベルを削除するだけで動作は同じ。 Real bug (1 件) =============== include/bomb_pessimistic.hh:622 - if (stat != Status::OK) { - std:stringstream ss; ss << "item id: " << node->i_id_; + if (stat != Status::OK) { + std::stringstream ss; ss << "item id: " << node->i_id_; コロン一つ抜けで、GCC は `std:` を unused label と解釈して通してしまって いた。`stringstream` 自体がスコープに見えていたのは cc/ss2pl/bomb_ss2pl.cc 側の `using namespace std;` (line 25) のせい — 起きる場所が ss2pl 経由の template instantiation だけだったので、ss2pl の bomb 系をビルドした時のみ 出現。-Wunused-label を error 化したことで掘り起こされた。 CMake ===== -Werror=maybe-uninitialized -Werror=unused-but-set-variable + -Werror=unused-label Test plan ========= - GCC 13 + Release / -ENABLE_SANITIZER=OFF: 34/34 - GCC 11 + Debug + ASan: 34/34
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 1 の最後の 1 つ。
-Wunused-label(7 件) を潰し、ccbench_add_protocol()に-Werror=unused-labelを追加する。Phase 1 これで完了。うち 6 件は dead label の整理、1 件は
std:typo の真のバグ修正。Dead labels (6 件)
複数の関数で同名の
FINISH_*ラベルが定義されていて、片方の関数ではgotoで使われているが、もう片方ではgoto参照が一切ない。各 warning 位置の 囲み関数を確認した上で、その関数内で実際に未使用のもののみ削除。同名でも別関数の現役gototarget は触らない。FINISH_READread_internalFINISH_DELETEdelete_recordFINISH_DELETEdelete_recordFINISH_VALIDATIONwrite_validationFINISH_VALIDATIONread_validationFINISH_READread_internalいずれも「関数末尾で
LABEL: <ADD_ANALYSIS の計測コード>; return ...;」の形。通常制御フローでそこに到達していたので、ラベル削除のみで動作は同じ。Real bug (1 件)
include/bomb_pessimistic.hh:622:
if (stat != Status::OK) { - std:stringstream ss; ss << "item id: " << node->i_id_; + std::stringstream ss; ss << "item id: " << node->i_id_; dump(tx.thid_, ss.str()); return nullptr; }コロン一つ抜けで、GCC は
std:を unused label と解釈して通してしまっていた。stringstream自体がスコープに見えていたのは cc/ss2pl/bomb_ss2pl.cc:25 のusing namespace std;のせい — 起きる場所が ss2pl 経由の template instantiation だけだったので、bomb_ss2pl系をビルドした時のみ表面化していた。-Werror=unused-labelを有効化したからこそ掘り起こされた、というのは #43 の趣旨そのもの。CMake
target_compile_options(${target} PRIVATE -Werror=maybe-uninitialized -Werror=unused-but-set-variable + -Werror=unused-label)Test plan
-DENABLE_SANITIZER=OFF: 34/34Phase 1 完了サマリ
-Wmaybe-uninitialized-Wunused-but-set-variable-Wunused-labelstd::typo 1ロードマップ通り 件数少 + 危険度高 から潰した。次は Phase 2 (
-Wignored-qualifiers30 件 →-Wsign-compare61 件)。