Repository navigation
Conversation
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. External sites
ReviewsSee the guideline and AI policy for information on the review process.
If your review is incorrectly listed, please copy-paste ConflictsReviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first. |
maflcko
left a comment
There was a problem hiding this comment.
Nice. lgtm. Left some style nits, but feel free to ignore.
../src/test/fuzz/fuzz.cpp:239:26: warning: code will never be executed [-Wunreachable-code]
This looks like a compiler bug?
|
🚧 At least one of the CI tasks failed. HintsTry to run the tests locally, according to the documentation. However, a CI failure may still
Leave a comment here, if you need help tracking down a confusing failure. |
78f74b1 to
906dd19
Compare
|
Opened bitcoin-core/leveldb-subtree#64 for the leveldb changes. |
|
🚧 At least one of the CI tasks failed. HintsTry to run the tests locally, according to the documentation. However, a CI failure may still
Leave a comment here, if you need help tracking down a confusing failure. |
411f42b to
d713ecf
Compare
a8321bc to
8d88646
Compare
|
🚧 At least one of the CI tasks failed. HintsTry to run the tests locally, according to the documentation. However, a CI failure may still
Leave a comment here, if you need help tracking down a confusing failure. |
16166b9 to
ab78cb5
Compare
|
Concept ACK |
|
Rebased. |
| static RPCMethod generate() | ||
| { | ||
| return RPCMethod{"generate", "has been replaced by the -generate cli option. Refer to -help for more information.", {}, {}, RPCExamples{""}, [](const RPCMethod& self, const JSONRPCRequest& request) -> UniValue { | ||
| return RPCMethod{"generate", "has been replaced by the -generate cli option. Refer to -help for more information.", {}, {}, RPCExamples{""}, [] [[noreturn]] (const RPCMethod& self, const JSONRPCRequest& request) -> UniValue { |
There was a problem hiding this comment.
basically the same question from before ( #35911 (review)):
A human reader will already see the throw, so for them this attribute doesn't add anything. And similarly for a compiler it doesn't add anything either, because it will be cast away from the lambda?
(Same for other lambdas, and virtual functions, etc)
There was a problem hiding this comment.
Took at look, and Clang <=21 (Ubuntu clang version 21.1.8 (6ubuntu1)), and I assume the equivalent version of Apple Clang, will warn without the attributes (some output below). I would rather leave a few (possibly redundant) annotations in place, and then just drop them once support for < Clang 22 is dropped?
[163/1145] Building CXX object src/wallet/CMakeFiles/bitcoin_wallet.dir/dump.cpp.o
/root/bitcoin/src/wallet/dump.cpp:54:24: warning: function 'operator()' could be declared with attribute 'noreturn' [-Wmissing-noreturn]
54 | auto throw_error = [](bilingual_str message) {
| ^
1 warning generated.
[276/1145] Building CXX object src/CMakeFiles/bitcoin_node.dir/node/interfaces.cpp.o
In file included from /root/bitcoin/src/node/interfaces.cpp:23:
/root/bitcoin/src/interfaces/mining.h:81:18: warning: function 'submitSolutionOld7' could be declared with attribute 'noreturn' [-Wmissing-noreturn]
81 | virtual bool submitSolutionOld7(uint32_t, uint32_t, uint32_t, CTransactionRef)
| ^
1 warning generated.
[282/1145] Building CXX object src/CMakeFiles/bitcoin_node.dir/rpc/node.cpp.o
In file included from /root/bitcoin/src/rpc/node.cpp:18:
In file included from /root/bitcoin/src/interfaces/init.h:15:
/root/bitcoin/src/interfaces/mining.h:81:18: warning: function 'submitSolutionOld7' could be declared with attribute 'noreturn' [-Wmissing-noreturn]
81 | virtual bool submitSolutionOld7(uint32_t, uint32_t, uint32_t, CTransactionRef)
| ^
In file included from /root/bitcoin/src/rpc/node.cpp:18:
/root/bitcoin/src/interfaces/init.h:51:18: warning: function 'makeMiningOld2' could be declared with attribute 'noreturn' [-Wmissing-noreturn]
51 | virtual void makeMiningOld2() { throw std::runtime_error("Old mining interface (@2) not supported. Please update your client!"); }
| ^
2 warnings generated.
[314/1145] Building CXX object src/CMakeFiles/bitcoin_node.dir/rpc/mining.cpp.o
/root/bitcoin/src/rpc/mining.cpp:288:146: warning: function 'operator()' could be declared with attribute 'noreturn' [-Wmissing-noreturn]
288 | return RPCMethod{"generate", "has been replaced by the -generate cli option. Refer to -help for more information.", {}, {}, RPCExamples{""}, [](const RPCMethod& self, const JSONRPCRequest& request) -> UniValue {
| ^
1 warning generated.There was a problem hiding this comment.
In Win Cross, Alpine, 32bit Arm i686 & previous releases:
/home/runner/work/_temp/src/test/util/net.cpp:238:11: error: function might be candidate for attribute ‘noreturn’ [-Werror=suggest-attribute=noreturn]
238 | ZeroSock& ZeroSock::operator=(Sock&& other)
| ^~~~~~~~
/home/runner/work/_temp/src/test/util/net.cpp: In member function ‘virtual StaticContentsSock& StaticContentsSock::operator=(Sock&&)’:
/home/runner/work/_temp/src/test/util/net.cpp:258:21: error: function might be candidate for attribute ‘noreturn’ [-Werror=suggest-attribute=noreturn]
258 | StaticContentsSock& StaticContentsSock::operator=(Sock&& other)
| ^~~~~~~~~~~~~~~~~~
/home/runner/work/_temp/src/test/util/net.cpp: In member function ‘virtual DynSock& DynSock::operator=(Sock&&)’:
/home/runner/work/_temp/src/test/util/net.cpp:378:10: error: function might be candidate for attribute ‘noreturn’ [-Werror=suggest-attribute=noreturn]
378 | DynSock& DynSock::operator=(Sock&&)
| ^~~~~~~There was a problem hiding this comment.
Added a link to this to the PR description.
There was a problem hiding this comment.
I would rather leave a few (possibly redundant) annotations in place, and then just drop them once support for < Clang 22 is dropped?
Should we add a TODO comment? Otherwise, it will be easy to forget to drop them when the time comes.
There was a problem hiding this comment.
I'm not sure if it's needed (this is also a few years away), and they are not only for Clang. Otherwise feel free to propose a diff.
5a6fd51 to
d627067
Compare
|
🚧 At least one of the CI tasks failed. HintsTry to run the tests locally, according to the documentation. However, a CI failure may still
Leave a comment here, if you need help tracking down a confusing failure. |
d627067 to
75b8304
Compare
75b8304 to
53ab81e
Compare
| virtual bool canListenIpc() { return false; } | ||
| virtual const char* exeName() { return nullptr; } | ||
| virtual void makeMiningOld2() { throw std::runtime_error("Old mining interface (@2) not supported. Please update your client!"); } | ||
| [[noreturn]] virtual void makeMiningOld2() { throw std::runtime_error("Old mining interface (@2) not supported. Please update your client!"); } |
There was a problem hiding this comment.
nit: it's a bit awkward to mark a virtual method as [[noreturn]] when an override can be implemented to return.
The libmultiprocess generated ProxyClient method overrides can return. I don't think anything in-tree calls makeMiningOld2 (or submitSolutionOld7) via IPC, but if that changes, a newer client (with noreturn) that calls an older server (that may return) can cause UB. The IPC interface is experimental, but at the same time the only reason we have these Old functions to handle version mismatches gracefully. Perhaps it makes sense to just not mark these kinds of functions as virtual?
There was a problem hiding this comment.
Clang 22.1 and later handles such cases correctly and emits no warning.
53ab81e to
1de12da
Compare
|
re-ACK 1de12da |
hebasto
left a comment
There was a problem hiding this comment.
The implementation of MakeWalletLoader() depends on the ENABLE_WALLET configuration variable.
We could use a pragma here:
--- a/src/dummywallet.cpp
+++ b/src/dummywallet.cpp
@@ -57,9 +57,18 @@ const WalletInitInterface& g_wallet_init_interface = DummyWalletInit();
namespace interfaces {
+#if defined(__GNUC__) || defined(__clang__)
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wmissing-noreturn"
+#endif
+
std::unique_ptr<WalletLoader> MakeWalletLoader(Chain& chain, ArgsManager& args)
{
throw std::logic_error("Wallet function called in non-wallet build.");
}
+#if defined(__GNUC__) || defined(__clang__)
+#pragma GCC diagnostic pop
+#endif
+
} // namespace interfaces1de12da to
9acce2a
Compare
|
Rebased for #37047 and addressed comments. |
Co-authored-by: stickies-v <[email protected]> Co-authored-by: Hennadii Stepanov <[email protected]>
9acce2a to
e15168a
Compare

Missing
[[noreturn]]attributes can cause compiler false positives and other issues; see discussion in #35896 (comment). Add missing attributes, and turn on compiler warnings.Some
[[noreturn]]additions may appear redundant, however they suppress warnings for various compiler versions, see discussion in #35911 (comment), and could be dropped in future, when support for those compilers is removed.Related:
bitcoin-core/libmultiprocess#339.
bitcoin-core/leveldb-subtree#64.
arun11299/cpp-subprocess#132.