Phase 3: -Wreorder を潰して -Werror=reorder を有効化 - #54
Merged
Conversation
#43 Phase 3 のサブタスク。-Wreorder の 20 件 (ユニーク) を潰し、 ccbench_add_protocol() に -Werror=reorder を追加する。 すべて TxExecutor (10 protocols) と TxNode (oze) のコンストラクタで member initializer list の順序がクラス内のメンバ宣言順と一致していな かったケース。C++ の初期化は宣言順で行われるため、initializer list の 順は無視され、見た目の順に初期化されると思い込むと UB の温床になる。 今回各箇所を「メンバが副作用を持たない (リファレンス bind / 単純なコ ピー / TxScanCallback(this) のような前提のない式)」ことを確認した上 で initializer の順序のみを宣言順に並べ替えた。意味的な動作変更はな し、ただし宣言順を変えないと潰せない箇所は無かった。 修正ファイル (12) ================= cc/cicada/include/transaction.hh:65 TxExecutor cc/d2pl/include/transaction.hh:60 TxExecutor cc/ermia/include/transaction.hh:57 TxExecutor cc/mocc/include/transaction.hh:62-63 TxExecutor (callback_ が先頭宣言) cc/mvto/include/transaction.hh:58 TxExecutor cc/oze/include/oze.hh:40-49 TxNode (2 個のコンストラクタ) cc/oze/include/transaction.hh:75 TxExecutor cc/si/include/transaction.hh:57 TxExecutor cc/silo/include/transaction.hh:69 TxExecutor cc/ss2pl/include/transaction.hh:46 TxExecutor cc/tictoc/include/transaction.hh:58 TxExecutor 各 protocol で order が違うのは、それぞれの TxExecutor クラスでメン バ宣言順が違うため。基本的に `thid_ -> result_ -> backoff_ -> quit_ -> callback_` のような形に揃っているが、cicada は `result_` の後に `quit_, callback_, backoff_, thid_` の宣言順、mocc は `callback_` が一番上にあるなど protocol ごとに微妙に違う。 真のバグ ======== 無し。順序を変えても挙動が変わるパターン (Foo(int x) : a_(x++), b_(x)) は無かった。すべて純粋な「混乱しやすい順序の整理」。 CMake ===== -Werror=maybe-uninitialized -Werror=unused-but-set-variable -Werror=unused-label + -Werror=reorder 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 3 のサブタスク。
-Wreorder(20 件ユニーク) を潰し、ccbench_add_protocol()に-Werror=reorderを追加する。修正概要
すべて TxExecutor (10 protocols) と TxNode (oze) のコンストラクタで member initializer list の順序がクラス内のメンバ宣言順と一致していなかったケース。C++ の初期化は宣言順で行われるので、initializer list の順は無視される。「見た目の順に初期化されている」と読み手が思い込むのを防ぐため、宣言順に並べ替え。
各箇所でメンバ初期化式に副作用が無いことを確認 (純粋なリファレンス bind / コピー /
TxScanCallback(this)のような前提のない式) してから順序のみを変更。挙動の変化は無し。修正ファイル
cc/cicada/include/transaction.hh:65TxExecutorcc/d2pl/include/transaction.hh:60TxExecutorcc/ermia/include/transaction.hh:57TxExecutorcc/mocc/include/transaction.hh:62-63TxExecutor(callback_が先頭宣言)cc/mvto/include/transaction.hh:58TxExecutorcc/oze/include/oze.hh:40-49TxNode(2 コンストラクタ)cc/oze/include/transaction.hh:75TxExecutorcc/si/include/transaction.hh:57TxExecutorcc/silo/include/transaction.hh:69TxExecutorcc/ss2pl/include/transaction.hh:46TxExecutorcc/tictoc/include/transaction.hh:58TxExecutor真のバグ
無し。順序変更で挙動が変わるパターン (
Foo(int x) : a_(x++), b_(x)のような副作用持ち) は混じっていなかった。CMake
target_compile_options(${target} PRIVATE -Werror=maybe-uninitialized -Werror=unused-but-set-variable - -Werror=unused-label) + -Werror=unused-label + -Werror=reorder)Test plan
-DENABLE_SANITIZER=OFF: 34/34Related