#35911 Warn on and add missing [[noreturn]]
https://github.com/bitcoin/bitcoin/pull/35911 · · +79/-65 in 20 files, 5 commits · labels: CI failed · draft
Goal
- Prevent false-positive compiler warnings on unreachable code paths
- Help compilers spot non-returning functions to improve diagnostics and optimizations
This pull request enables the `-Wmissing-noreturn` compiler warning flag in CMake and adds the `[[noreturn]]` attribute to functions, methods, and lambdas that do not return (such as fatal exit handlers, abort paths, and unconditional throwers). It also adapts build pragmas and transitions several raw `exit()` calls to `std::exit()`.
Problem: Missing `[[noreturn]]` attributes can cause compilers to issue false-positive warnings (such as unreachable code or uninitialized variable warnings) and miss potential code optimizations.
Category: Build and CI (#39 of 55)
P3 · cleanup
- P3 because it offers minor leverage for future code by catching missing attributes
- Has no urgency or direct user-facing impact
Enabling `-Wmissing-noreturn` improves compiler diagnostics and avoids false positives on unreachable code paths. It is an internal build hygiene enhancement with minor leverage across future code, but carries no urgency or user-facing impact.
Membership: Modifies CMakeLists.txt to add compiler warning flags (-Wmissing-noreturn and -Wc++23-lambda-attributes).
Factors: security/stability 0, bug 0, performance 0, user value 0, leverage 1
Reviewability: Paused: Waiting on libmultiprocess
- Paused by author until an upstream libmultiprocess subtree update
- Windows CI is currently failing
Author stated on 2026-08-18 that the PR will remain in draft until the next libmultiprocess subtree update, and CI is currently failing on Windows.
Author status: Paused; author indicated the PR will remain in draft until the next libmultiprocess subtree update.
Open concerns:
- Compilation failures on Windows with clang-cl and MSVC.
- Requires an upstream libmultiprocess subtree update to avoid out-of-tree diffs.
Resolved concerns:
- Addressed style nits and line formatting in test files.
- Handled C++23 lambda attribute warnings under Clang with a dedicated warning flag suppression.
Agreement: Positive
- Concept approval without stated reasons (hebasto, stickies-v)
- Support with help diagnosing Clang and Windows warning issues (maflcko)
Positive concept feedback from multiple contributors with no fundamental objections.
Reviewers welcomed the compiler warning addition, noting only minor style suggestions and Windows compilation issues.
- hebasto gave Concept ACK
- stickies-v gave Concept ACK
- maflcko commented 'Nice. lgtm' and helped diagnose compiler warning issues on Clang and Windows
Review verdicts (DrahtBot): 0
- Concept ACK: hebasto, stickies-v
Files
115 lines under test/bench/ci.
- src/test/fuzz/fuzz.cpp +50/-41
- src/test/util/net.h +3/-3
- CMakeLists.txt +5/-0
- src/sync.cpp +2/-2
- src/test/threadpool_tests.cpp +3/-1
- src/test/util/setup_common.cpp +2/-2
- src/bitcoind.cpp +2/-1
- src/qt/bitcoin.cpp +2/-1
- src/test/util/net.cpp +0/-3
- src/interfaces/init.h +1/-1
- src/interfaces/mining.h +1/-1
- src/ipc/libmultiprocess/include/mp/proxy-types.h +1/-1
- src/ipc/libmultiprocess/test/mp/test/foo.h +1/-1
- src/qt/bitcoin.h +1/-1
- src/rpc/mining.cpp +1/-1
- src/test/fuzz/dbwrapper.cpp +1/-1
- src/test/fuzz/threadpool.cpp +1/-1
- src/test/fuzz/util/net.h +1/-1
- src/util/subprocess.h +1/-1
- src/test/fuzz/util/net.cpp +0/-1
Card
PR #35911 enables the -Wmissing-noreturn compiler warning flag in CMake and annotates non-returning functions and lambdas across the codebase with [[noreturn]]. The change prevents compiler false positives and helps optimize dead-end branches. The concept is supported without objection, but the PR is currently paused in draft while waiting on an upstream libmultiprocess subtree update and resolving Windows compiler failures.