Warn on and add missing `[[noreturn]]` #35911

pull fanquake wants to merge 4 commits into bitcoin:master from fanquake:missing_noreturn changing 20 files +59 −43
  1. fanquake commented at 9:34 AM on August 6, 2026: member

    Missing [[noreturn]] attributes can cause compiler false positives and other issues; see discussion in #35896 (review). 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 (review), and could be dropped in future, when support for those compilers is removed.

    Related: https://github.com/bitcoin-core/libmultiprocess/pull/339. https://github.com/bitcoin-core/leveldb-subtree/pull/64. https://github.com/arun11299/cpp-subprocess/pull/132.

  2. DrahtBot commented at 9:34 AM on August 6, 2026: contributor

    <!--e57a25ab6845829454e8d69fc972939a-->

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    <!--006a51241073e994b41acfe9ec718e94-->

    External sites

    <!--021abf342d371248e50ceaed478a90ca-->

    Reviews

    See the guideline and AI policy for information on the review process.

    Type Reviewers
    ACK stickies-v
    Concept ACK hebasto

    If your review is incorrectly listed, please copy-paste <code>&lt;!--meta-tag:bot-skip--&gt;</code> into the comment that the bot should ignore.

    <!--174a7506f384e20aa4161008e828411d-->

    Conflicts

    Reviewers, this pull request conflicts with the following ones:

    • #bitcoin-core/gui/945 <sub><img src="https://drahtbot.space/ack_count/bitcoin-core/gui/945.svg"></sub> (Fix sign message address book filtering by Bushstar)
    • #36897 <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36897.svg"></sub> (wallet, migration: Contain all legacy wallet and migration related things in its own subdirectory, namespace, and classes by achow101)
    • #36820 <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36820.svg"></sub> (refactor: remove more dead code by fanquake)
    • #36743 <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36743.svg"></sub> ([RFC] build: build with -Wmissing-declarations/prototypes by fanquake)
    • #36689 <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36689.svg"></sub> (cli: Parse -signetchallenge like bitcoind by ekzyis)
    • #36598 <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36598.svg"></sub> ([Demo] validation: remove AssumeUTXO by l0rinc)
    • #36549 <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36549.svg"></sub> (WIP: improve MallocUsage and test in CI by sipa)
    • #36434 <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36434.svg"></sub> (http: support unix sockets by pinheadmz)
    • #36167 <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36167.svg"></sub> (build: Enable -Wunused by fanquake)
    • #36122 <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36122.svg"></sub> (BIP460: CISA for Taproot key path spends by fjahr)
    • #36087 <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36087.svg"></sub> (util: Add and use AssertUnreachable by maflcko)
    • #35713 <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/35713.svg"></sub> (Remove boost as a unit test runner by rustaceanrob)
    • #35355 <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/35355.svg"></sub> (Use atomics for determining whether trace logging is enabled by ajtowns)
    • #35302 <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/35302.svg"></sub> (Silent Payments: Sending (take 2) by Eunovo)
    • #34909 <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/34909.svg"></sub> (wallet, refactor: modularise wallet by extracting out legacy wallet migration by rkrux)
    • #34193 <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/34193.svg"></sub> (wallet: make migration more robust against failures by furszy)
    • #34132 <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/34132.svg"></sub> (coins,dbwrapper: make point-read and txindex lookup failures fatal by l0rinc)
    • #32575 <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/32575.svg"></sub> (consensus: Remove special treatment for single threaded script checking by fjahr)

    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.

    <!--5faf32d7da4f0f540f40219e4f7537a3-->

  3. in src/test/util/setup_common.cpp:139 in 78f74b1a29 outdated
     132 | @@ -133,7 +133,7 @@ void SetupCommonTestArgs(ArgsManager& argsman)
     133 |  }
     134 |  
     135 |  /** Test setup failure */
     136 | -static void ExitFailure(std::string_view str_err)
     137 | +[[noreturn]] static void ExitFailure(std::string_view str_err)
     138 |  {
     139 |      std::cerr << str_err << std::endl;
     140 |      exit(EXIT_FAILURE);
    


    maflcko commented at 9:52 AM on August 6, 2026:

    nit: Should probably use std::exit https://en.cppreference.com/cpp/utility/program/exit

    to avoid confusing with the one from C23?

    But either is fine and I don't think this matters.


    fanquake commented at 10:38 AM on August 6, 2026:

    Added a commit for this.

  4. in src/test/threadpool_tests.cpp:212 in 78f74b1a29 outdated
     208 | @@ -209,7 +209,7 @@ BOOST_AUTO_TEST_CASE(task_exception_propagates_to_future)
     209 |      std::vector<std::future<void>> futures;
     210 |      futures.reserve(num_tasks);
     211 |      for (int i = 0; i < num_tasks; i++) {
     212 | -        futures.emplace_back(Submit(threadPool, [&make_err, i] { throw std::runtime_error(make_err(i)); }));
     213 | +        futures.emplace_back(Submit(threadPool, [&make_err, i]() __attribute__((noreturn)) { throw std::runtime_error(make_err(i)); }));
    


    maflcko commented at 9:53 AM on August 6, 2026:

    nit: Can probably split/clang-format this long line into 3 or so?

            futures.emplace_back(Submit(threadPool, [&make_err, i]() __attribute__((noreturn)) {
              throw std::runtime_error(make_err(i));
               }));
    

    fanquake commented at 4:36 PM on August 6, 2026:

    Split this up.

  5. in src/util/subprocess.h:751 in 78f74b1a29 outdated
     747 | @@ -748,7 +748,7 @@ class Child
     748 |      err_wr_pipe_(err_wr_pipe)
     749 |    {}
     750 |  
     751 | -  void execute_child();
     752 | +  [[noreturn]] void execute_child();
    


    maflcko commented at 9:53 AM on August 6, 2026:

    Could also add upstream, but doesn't matter for this pull.


    fanquake commented at 10:06 AM on August 6, 2026:
  6. maflcko commented at 9:59 AM on August 6, 2026: member

    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?

  7. DrahtBot added the label CI failed on Aug 6, 2026
  8. DrahtBot commented at 10:05 AM on August 6, 2026: contributor

    <!--85328a0da195eb286784d51f73fa0af9-->

    🚧 At least one of the CI tasks failed. <sub>Task test ancestor commits: https://github.com/bitcoin/bitcoin/actions/runs/31089666107/job/92577355450</sub> <sub>LLM reason (✨ experimental): CI failed at build time because clang with -Werror rejected fuzz test code in src/test/fuzz/fuzz.cpp (invalid noreturn function return and unreachable code).</sub>

    <details><summary>Hints</summary>

    Try to run the tests locally, according to the documentation. However, a CI failure may still happen due to a number of reasons, for example:

    • Possibly due to a silent merge conflict (the changes in this pull request being incompatible with the current code in the target branch). If so, make sure to rebase on the latest commit of the target branch.

    • A sanitizer issue, which can only be found by compiling with the sanitizer and running the affected test.

    • An intermittent issue.

    Leave a comment here, if you need help tracking down a confusing failure.

    </details>

  9. in src/test/fuzz/fuzz.cpp:93 in 78f74b1a29
      89 | @@ -90,7 +90,7 @@ const std::function<std::string()> G_TEST_GET_FULL_NAME{[]{
      90 |      return std::string{g_fuzz_target};
      91 |  }};
      92 |  
      93 | -static void initialize()
      94 | +[[noreturn]] static void initialize()
    


    maflcko commented at 10:10 AM on August 6, 2026:

    Oh, I missed: This one is wrong:

    cd /home/runner/work/bitcoin/bitcoin/ci_build/src/test/fuzz/util && /usr/bin/ccache /usr/bin/clang++ -DABORT_ON_FAILED_ASSUME -DBOOST_MULTI_INDEX_DISABLE_SERIALIZATION -DBOOST_NO_CXX98_FUNCTION_BASE -DDEBUG -DDEBUG_LOCKCONTENTION -DDEBUG_LOCKORDER -DPROVIDE_FUZZ_MAIN_FUNCTION -DRPC_DOC_CHECK -I/home/runner/work/bitcoin/bitcoin/ci_build/src -I/home/runner/work/bitcoin/bitcoin/src -I/home/runner/work/bitcoin/bitcoin/src/univalue/include -Wno-error=unused-member-function -Wno-error=unused-function -O0 -ftrapv -g3 -std=c++20 -fPIC -fmacro-prefix-map=/home/runner/work/bitcoin/bitcoin/src=. -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3 -Wstack-protector -fstack-protector-all -fcf-protection=full -fstack-clash-protection -Wall -Wextra -Wgnu -Wcovered-switch-default -Wformat -Wformat-security -Wvla -Wshadow-field -Wthread-safety -Wloop-analysis -Wredundant-decls -Wunused-member-function -Wdate-time -Wconditional-uninitialized -Woverloaded-virtual -Wsuggest-override -Wimplicit-fallthrough -Wunreachable-code -Wdocumentation -Wself-assign -Wundef -Wno-unused-parameter -Werror -MD -MT src/test/fuzz/util/CMakeFiles/test_fuzz.dir/__/fuzz.cpp.o -MF CMakeFiles/test_fuzz.dir/__/fuzz.cpp.o.d -o CMakeFiles/test_fuzz.dir/__/fuzz.cpp.o -c /home/runner/work/bitcoin/bitcoin/src/test/fuzz/fuzz.cpp  -O3 -g2
    /home/runner/work/bitcoin/bitcoin/src/test/fuzz/fuzz.cpp:168:1: error: function declared 'noreturn' should not return [-Werror,-Winvalid-noreturn]
      168 | }
          | ^
    /home/runner/work/bitcoin/bitcoin/src/test/fuzz/fuzz.cpp:239:26: error: code will never be executed [-Werror,-Wunreachable-code]
      239 |     std::vector<uint8_t> buffer;
          |                          ^~~~~~
    2 errors generated.
    

    maflcko commented at 12:41 PM on August 6, 2026:

    Mabye a bug in clang: https://github.com/bitcoin/bitcoin/actions/runs/31093885302/job/92591251807?pr=35911#step:11:3252:

    cd "/home/runner/work/_temp/build_ ₿🧪_/src/test/fuzz/util" && /usr/bin/ccache /usr/bin/clang++ -DBOOST_MULTI_INDEX_DISABLE_SERIALIZATION -DBOOST_NO_CXX98_FUNCTION_BASE -DPROVIDE_FUZZ_MAIN_FUNCTION -I"/home/runner/work/_temp/build_ ₿🧪_/src" -I/home/runner/work/_temp/src -I/home/runner/work/_temp/src/univalue/include -ftrivial-auto-var-init=pattern -O2 -g -std=c++20 -fPIC -fmacro-prefix-map=/home/runner/work/_temp/src=. -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3 -Wstack-protector -fstack-protector-all -fcf-protection=full -fstack-clash-protection -fsanitize=address,float-divide-by-zero,integer,undefined -Wall -Wextra -Wgnu -Wcovered-switch-default -Wformat -Wformat-security -Wvla -Wshadow-field -Wthread-safety -Wthread-safety-pointer -Wloop-analysis -Wredundant-decls -Wunused-member-function -Wdate-time -Wconditional-uninitialized -Woverloaded-virtual -Wsuggest-override -Wimplicit-fallthrough -Wunreachable-code -Wdocumentation -Wself-assign -Wundef -Wmissing-noreturn -Wno-unused-parameter -Werror -MD -MT src/test/fuzz/util/CMakeFiles/test_fuzz.dir/__/fuzz.cpp.o -MF CMakeFiles/test_fuzz.dir/__/fuzz.cpp.o.d -o CMakeFiles/test_fuzz.dir/__/fuzz.cpp.o -c /home/runner/work/_temp/src/test/fuzz/fuzz.cpp -DARENA_DEBUG -DDEBUG_LOCKORDER -std=c++23
    /home/runner/work/_temp/src/test/fuzz/fuzz.cpp:94:1: error: function 'initialize' could be declared with attribute 'noreturn' [-Werror,-Wmissing-noreturn]
       94 | {
          | ^
    1 error generated.
    
    
  10. fanquake force-pushed on Aug 6, 2026
  11. maflcko removed the label CI failed on Aug 6, 2026
  12. fanquake commented at 10:34 AM on August 6, 2026: member
  13. DrahtBot added the label CI failed on Aug 6, 2026
  14. DrahtBot commented at 10:36 AM on August 6, 2026: contributor

    <!--85328a0da195eb286784d51f73fa0af9-->

    🚧 At least one of the CI tasks failed. <sub>Task lint: https://github.com/bitcoin/bitcoin/actions/runs/31093313597/job/92589235946</sub> <sub>LLM reason (✨ experimental): CI failed because the lint check subtree detected that a subtree directory was modified without the required subtree merge.</sub>

    <details><summary>Hints</summary>

    Try to run the tests locally, according to the documentation. However, a CI failure may still happen due to a number of reasons, for example:

    • Possibly due to a silent merge conflict (the changes in this pull request being incompatible with the current code in the target branch). If so, make sure to rebase on the latest commit of the target branch.

    • A sanitizer issue, which can only be found by compiling with the sanitizer and running the affected test.

    • An intermittent issue.

    Leave a comment here, if you need help tracking down a confusing failure.

    </details>

  15. in CMakeLists.txt:505 in 906dd19986 outdated
     501 | @@ -502,6 +502,7 @@ else()
     502 |    try_append_cxx_flags("-Wundef" TARGET warn_interface SKIP_LINK)
     503 |    try_append_cxx_flags("-Wleading-whitespace=spaces" TARGET warn_interface SKIP_LINK)
     504 |    try_append_cxx_flags("-Wtrailing-whitespace=any" TARGET warn_interface SKIP_LINK)
     505 | +  try_append_cxx_flags("-Wmissing-noreturn" TARGET warn_interface SKIP_LINK)
    


    Sjors commented at 11:57 AM on August 6, 2026:

    Documentation says:

    Note these are only possible candidates, not absolute ones.

    So this might give us false positives, but those could be suppressed?

    https://gcc.gnu.org/onlinedocs/gcc-4.2.2/gcc/Warning-Options.html


    fanquake commented at 12:39 PM on August 6, 2026:

    https://gcc.gnu.org/onlinedocs/gcc-4.2.2/gcc/Warning-Options.html

    Your documentation is about 20 years out of date. The modern docs say:

    Warn about functions that might be candidates for attributes pure, const, noreturn, malloc or returns_nonnull. The compiler only warns for functions visible in other compilation units or (in the case of pure and const) if it cannot prove that the function returns normally. A function returns normally if it doesn’t contain an infinite loop or return abnormally by throwing, calling abort or trapping. This analysis requires option -fipa-pure-const, which is enabled by default at -O and higher. Higher optimization levels improve the accuracy of the analysis.

  16. hebasto commented at 3:39 PM on August 6, 2026: member

    Concept ACK.

  17. hebasto commented at 4:26 PM on August 6, 2026: member

    Could you submit commit 2b6dee1f51651ecf7245552b467417cc72a28fe3 in a separate PR? That way, we can review and land it sooner to unbreak the nightly CI.

  18. fanquake commented at 4:28 PM on August 6, 2026: member

    Could you submit commit https://github.com/bitcoin/bitcoin/commit/2b6dee1f51651ecf7245552b467417cc72a28fe3 in a separate PR?

    It is part of #35896.

  19. fanquake force-pushed on Aug 6, 2026
  20. fanquake force-pushed on Aug 7, 2026
  21. fanquake force-pushed on Aug 7, 2026
  22. maflcko removed the label CI failed on Aug 7, 2026
  23. DrahtBot added the label CI failed on Aug 7, 2026
  24. DrahtBot commented at 10:04 AM on August 7, 2026: contributor

    <!--85328a0da195eb286784d51f73fa0af9-->

    🚧 At least one of the CI tasks failed. <sub>Task lint: https://github.com/bitcoin/bitcoin/actions/runs/31164196113/job/92821231499</sub> <sub>LLM reason (✨ experimental): CI failed because the linter’s “subtree” check detected modified subtree directories without a corresponding subtree merge.</sub>

    <details><summary>Hints</summary>

    Try to run the tests locally, according to the documentation. However, a CI failure may still happen due to a number of reasons, for example:

    • Possibly due to a silent merge conflict (the changes in this pull request being incompatible with the current code in the target branch). If so, make sure to rebase on the latest commit of the target branch.

    • A sanitizer issue, which can only be found by compiling with the sanitizer and running the affected test.

    • An intermittent issue.

    Leave a comment here, if you need help tracking down a confusing failure.

    </details>

  25. fanquake force-pushed on Aug 7, 2026
  26. fanquake force-pushed on Aug 10, 2026
  27. stickies-v commented at 10:30 AM on August 11, 2026: contributor

    Concept ACK

  28. fanquake referenced this in commit 13da2d6758 on Aug 11, 2026
  29. sedited referenced this in commit c1967c4453 on Aug 11, 2026
  30. fanquake referenced this in commit 636aaff576 on Aug 12, 2026
  31. ryanofsky referenced this in commit bdd0cd6941 on Aug 12, 2026
  32. fanquake force-pushed on Aug 12, 2026
  33. fanquake force-pushed on Aug 12, 2026
  34. fanquake referenced this in commit 0274dd3b6a on Aug 12, 2026
  35. fanquake force-pushed on Aug 12, 2026
  36. fanquake referenced this in commit 36d172695f on Aug 12, 2026
  37. fanquake referenced this in commit b0399cdb70 on Aug 12, 2026
  38. fanquake referenced this in commit 8b5da677d7 on Aug 14, 2026
  39. fanquake referenced this in commit e95bab98f0 on Aug 14, 2026
  40. fanquake force-pushed on Aug 14, 2026
  41. fanquake force-pushed on Aug 18, 2026
  42. fanquake commented at 10:13 AM on August 18, 2026: member

    Not sure it's worth trying to pull any changes out here, so this will remain drafted until the next libmultiprocess subtree update.

  43. xyzconstant referenced this in commit 8c84be5cc8 on Aug 27, 2026
  44. in src/test/fuzz/util/net.h:195 in afff3e70d7 outdated
     191 | @@ -192,7 +192,7 @@ class FuzzedSock : public Sock
     192 |  
     193 |      ~FuzzedSock() override;
     194 |  
     195 | -    FuzzedSock& operator=(Sock&& other) override;
     196 | +    [[noreturn]] FuzzedSock& operator=(Sock&& other) override;
    


    maflcko commented at 8:41 AM on August 31, 2026:

    Looks like this still fails to compile on Windows for both clang-cl and MSVC? IIRC I tried this last week on godbolt and for some reason inlining the impl into the header worked around the bug.


    maflcko commented at 7:38 PM on November 10, 2026:

    Not sure how this passes now, but I don' think we want to merge this in its current form. Devs will just have to fight the compiler matrix, without knowing what to do:

    • assert(false) doesn't work on Clang-Cl.
    • Assert(false) doesn't' work on GCC.
    • Randomly placed std::abort are unclear if they mean unreachable code or just a "normal" abort, because the program can't continue for whatever reason. Also, they don't have any debug prints.

    I've fixed this in https://github.com/bitcoin/bitcoin/pull/36087


    fanquake commented at 8:21 PM on November 10, 2026:

    Sure. Rebased on that branch.

  45. fanquake force-pushed on Sep 9, 2026
  46. fanquake force-pushed on Sep 29, 2026
  47. ajtowns referenced this in commit f84a0750f3 on Oct 23, 2026
  48. DrahtBot added the label Needs rebase on Nov 4, 2026
  49. fanquake referenced this in commit 93bd4e1df4 on Nov 5, 2026
  50. fanquake force-pushed on Nov 5, 2026
  51. DrahtBot removed the label Needs rebase on Nov 5, 2026
  52. fanquake force-pushed on Nov 5, 2026
  53. fanquake commented at 4:44 PM on November 5, 2026: member

    Rebased and should now be reviewable.

  54. fanquake marked this as ready for review on Nov 5, 2026
  55. DrahtBot removed the label CI failed on Nov 5, 2026
  56. fanquake force-pushed on Nov 6, 2026
  57. fanquake commented at 11:14 AM on November 6, 2026: member

    Rebased again, after #36036.

  58. fanquake renamed this:
    Warn on and add missing [[noreturn]]
    Warn on and add missing `[[noreturn]]`
    on Nov 9, 2026
  59. fanquake requested review from hebasto on Nov 9, 2026
  60. hebasto commented at 7:50 PM on November 9, 2026: member

    Assuming that the added attributes were prompted by compiler warnings, I wonder which exact compiler was used.

    I’m asking because on Fedora 45 with Clang 23.1.5, I was able to build without any compiler warnings after applying the following partial revert of the first commit:

    diff --git a/src/interfaces/init.h b/src/interfaces/init.h
    index daf6b8d58e..2f3aeb6aff 100644
    --- a/src/interfaces/init.h
    +++ b/src/interfaces/init.h
    @@ -48,7 +48,7 @@ public:
         virtual Ipc* ipc() { return nullptr; }
         virtual bool canListenIpc() { return false; }
         virtual const char* exeName() { return nullptr; }
    -    [[noreturn]] virtual void makeMiningOld2() { throw std::runtime_error("Old mining interface (@2) not supported. Please update your client!"); }
    +    virtual void makeMiningOld2() { throw std::runtime_error("Old mining interface (@2) not supported. Please update your client!"); }
     };
     
     //! Return implementation of Init interface for the node process. If the argv
    diff --git a/src/interfaces/mining.h b/src/interfaces/mining.h
    index 323859708c..c8e969711b 100644
    --- a/src/interfaces/mining.h
    +++ b/src/interfaces/mining.h
    @@ -78,7 +78,7 @@ public:
     
         //! Deprecated older method preserved to return an explicit error for IPC
         //! clients using mining.capnp [@7](/bitcoin-bitcoin/contributor/7/).
    -    [[noreturn]] virtual bool submitSolutionOld7(uint32_t, uint32_t, uint32_t, CTransactionRef)
    +    virtual bool submitSolutionOld7(uint32_t, uint32_t, uint32_t, CTransactionRef)
         {
             throw std::runtime_error("Old submitSolution (@7) not supported. Please update your client!");
         }
    diff --git a/src/rpc/mining.cpp b/src/rpc/mining.cpp
    index ea55988cf0..4f375a90f2 100644
    --- a/src/rpc/mining.cpp
    +++ b/src/rpc/mining.cpp
    @@ -286,7 +286,7 @@ static RPCMethod generatetodescriptor()
     
     static RPCMethod generate()
     {
    -    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 {
    +    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 {
             throw JSONRPCError(RPC_METHOD_NOT_FOUND, self.ToString());
         }};
     }
    diff --git a/src/sync.cpp b/src/sync.cpp
    index 7ee098e7b7..1acbe3cf06 100644
    --- a/src/sync.cpp
    +++ b/src/sync.cpp
    @@ -104,7 +104,7 @@ LockData& GetLockData() {
         return lock_data;
     }
     
    -[[noreturn]] static void potential_deadlock_detected(const LockPair& mismatch, const LockStack& s1, const LockStack& s2)
    +static void potential_deadlock_detected(const LockPair& mismatch, const LockStack& s1, const LockStack& s2)
     {
         LogError("POTENTIAL DEADLOCK DETECTED");
         LogError("Previous lock order was:");
    @@ -140,7 +140,7 @@ LockData& GetLockData() {
         throw std::logic_error(strprintf("potential deadlock detected: %s -> %s -> %s", mutex_b, mutex_a, mutex_b));
     }
     
    -[[noreturn]] static void double_lock_detected(const void* mutex, const LockStack& lock_stack)
    +static void double_lock_detected(const void* mutex, const LockStack& lock_stack)
     {
         LogError("DOUBLE LOCK DETECTED");
         LogError("Lock order:");
    diff --git a/src/test/fuzz/util/net.h b/src/test/fuzz/util/net.h
    index 602dc093e4..520c6732da 100644
    --- a/src/test/fuzz/util/net.h
    +++ b/src/test/fuzz/util/net.h
    @@ -192,7 +192,7 @@ public:
     
         ~FuzzedSock() override;
     
    -    [[noreturn]] FuzzedSock& operator=(Sock&& other) override;
    +    FuzzedSock& operator=(Sock&& other) override;
     
         ssize_t Send(const void* data, size_t len, int flags) const override;
     
    diff --git a/src/test/threadpool_tests.cpp b/src/test/threadpool_tests.cpp
    index 3576428552..4811d73215 100644
    --- a/src/test/threadpool_tests.cpp
    +++ b/src/test/threadpool_tests.cpp
    @@ -209,9 +209,7 @@ BOOST_AUTO_TEST_CASE(task_exception_propagates_to_future)
         std::vector<std::future<void>> futures;
         futures.reserve(num_tasks);
         for (int i = 0; i < num_tasks; i++) {
    -        futures.emplace_back(Submit(threadPool, [&make_err, i] [[noreturn]] () {
    -          throw std::runtime_error(make_err(i));
    -        }));
    +        futures.emplace_back(Submit(threadPool, [&make_err, i] { throw std::runtime_error(make_err(i)); }));
         }
     
         for (int i = 0; i < num_tasks; i++) {
    diff --git a/src/test/util/net.h b/src/test/util/net.h
    index 1f2e97b88e..8014bbcc36 100644
    --- a/src/test/util/net.h
    +++ b/src/test/util/net.h
    @@ -201,7 +201,7 @@ public:
         bool WaitMany(std::chrono::milliseconds timeout, EventsPerSock& events_per_sock) const override;
     
     private:
    -    [[noreturn]] ZeroSock& operator=(Sock&& other) override;
    +    ZeroSock& operator=(Sock&& other) override;
     };
     
     /**
    @@ -226,7 +226,7 @@ public:
         }
     
     private:
    -    [[noreturn]] StaticContentsSock& operator=(Sock&& other) override;
    +    StaticContentsSock& operator=(Sock&& other) override;
     
         const std::string m_contents;
         mutable size_t m_consumed{0};
    @@ -362,7 +362,7 @@ public:
         bool WaitMany(std::chrono::milliseconds timeout, EventsPerSock& events_per_sock) const override;
     
     private:
    -    [[noreturn]] DynSock& operator=(Sock&&) override;
    +    DynSock& operator=(Sock&&) override;
     
         std::shared_ptr<Pipes> m_pipes;
         Queue* const m_accept_sockets;
    diff --git a/src/wallet/dump.cpp b/src/wallet/dump.cpp
    index ae50d777a1..c76ccd427b 100644
    --- a/src/wallet/dump.cpp
    +++ b/src/wallet/dump.cpp
    @@ -51,7 +51,7 @@ bool DumpWallet(const ArgsManager& args, WalletDatabase& db, bilingual_str& erro
         struct DumpWalletError {
             bilingual_str message;
         };
    -    auto throw_error = [] [[noreturn]] (bilingual_str message) {
    +    auto throw_error = [](bilingual_str message) {
             throw DumpWalletError{std::move(message)};
         };
         auto throw_write_error = [&] {
    
  61. fanquake commented at 10:19 PM on November 9, 2026: member

    Assuming that the added attributes were prompted by compiler warnings, I wonder which exact compiler was used.

    They have just been added to functions that don't return; irrespective of whether any particular compiler, or version of, may or may not have warned.

  62. fanquake force-pushed on Nov 10, 2026
  63. DrahtBot added the label Needs rebase on Nov 16, 2026
  64. fanquake marked this as a draft on Nov 16, 2026
  65. fanquake force-pushed on Nov 18, 2026
  66. DrahtBot removed the label Needs rebase on Nov 18, 2026
  67. DrahtBot added the label CI failed on Nov 18, 2026
  68. DrahtBot commented at 11:33 AM on November 18, 2026: contributor

    <!--85328a0da195eb286784d51f73fa0af9-->

    🚧 At least one of the CI tasks failed. <sub>Task lint: https://github.com/bitcoin/bitcoin/actions/runs/44286334548/job/134739857781</sub> <sub>LLM reason (✨ experimental): CI failed lint checks: assert_falsy flags assert(false) in src/test/fuzz/util/wallet.h, and the scripted-diff check also failed.</sub>

    <details><summary>Hints</summary>

    Try to run the tests locally, according to the documentation. However, a CI failure may still happen due to a number of reasons, for example:

    • Possibly due to a silent merge conflict (the changes in this pull request being incompatible with the current code in the target branch). If so, make sure to rebase on the latest commit of the target branch.

    • A sanitizer issue, which can only be found by compiling with the sanitizer and running the affected test.

    • An intermittent issue.

    Leave a comment here, if you need help tracking down a confusing failure.

    </details>

  69. DrahtBot added the label Needs rebase on Nov 20, 2026
  70. fanquake force-pushed on Nov 21, 2026
  71. fanquake marked this as ready for review on Nov 21, 2026
  72. fanquake commented at 8:51 AM on November 21, 2026: member

    Rebased.

  73. DrahtBot removed the label CI failed on Nov 21, 2026
  74. DrahtBot removed the label Needs rebase on Nov 21, 2026
  75. in src/rpc/mining.cpp:288 in 5a6fd51484 outdated
     284 | @@ -285,7 +285,7 @@ static RPCMethod generatetodescriptor()
     285 |  
     286 |  static RPCMethod generate()
     287 |  {
     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 {
     289 | +    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 {
    


    maflcko commented at 12:57 PM on November 22, 2026:

    basically the same question from before ( #35911#pullrequestreview-5831762867):

    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)


    fanquake commented at 2:58 PM on November 22, 2026:

    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.
    

    fanquake commented at 5:21 PM on November 22, 2026:

    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&&)
          |          ^~~~~~~
    

    maflcko commented at 7:16 AM on November 23, 2026:

    ok, I see. Seems fine then


    fanquake commented at 11:01 AM on November 23, 2026:

    Added a link to this to the PR description.

  76. fanquake force-pushed on Nov 22, 2026
  77. DrahtBot added the label CI failed on Nov 22, 2026
  78. DrahtBot commented at 3:45 PM on November 22, 2026: contributor

    <!--85328a0da195eb286784d51f73fa0af9-->

    🚧 At least one of the CI tasks failed. <sub>Task Alpine (musl): https://github.com/bitcoin/bitcoin/actions/runs/45035866867/job/137249377761</sub> <sub>LLM reason (✨ experimental): The build failed because -Werror promoted GCC’s suggest-attribute=noreturn warnings in src/test/util/net.cpp to errors.</sub>

    <details><summary>Hints</summary>

    Try to run the tests locally, according to the documentation. However, a CI failure may still happen due to a number of reasons, for example:

    • Possibly due to a silent merge conflict (the changes in this pull request being incompatible with the current code in the target branch). If so, make sure to rebase on the latest commit of the target branch.

    • A sanitizer issue, which can only be found by compiling with the sanitizer and running the affected test.

    • An intermittent issue.

    Leave a comment here, if you need help tracking down a confusing failure.

    </details>

  79. fanquake force-pushed on Nov 22, 2026
  80. DrahtBot removed the label CI failed on Nov 22, 2026
  81. fanquake requested review from stickies-v on Nov 23, 2026
  82. fanquake force-pushed on Nov 23, 2026
  83. in src/test/fuzz/fuzz.cpp:1 in 53ab81e539 outdated


    stickies-v commented at 11:17 AM on November 23, 2026:

    nit: I think this can be done with a lot less code churn by just moving LLVMFuzzerInitialize next to initialize?

    <details> <summary>git diff on 75b8304271</summary>

    diff --git a/src/test/fuzz/fuzz.cpp b/src/test/fuzz/fuzz.cpp
    index 97e185a577..b740ec0ac8 100644
    --- a/src/test/fuzz/fuzz.cpp
    +++ b/src/test/fuzz/fuzz.cpp
    @@ -90,47 +90,6 @@ const std::function<std::string()> G_TEST_GET_FULL_NAME{[]{
         return std::string{g_fuzz_target};
     }};
     
    -#if defined(PROVIDE_FUZZ_MAIN_FUNCTION)
    -static bool read_stdin(std::vector<uint8_t>& data)
    -{
    -    std::istream::char_type buffer[1024];
    -    std::streamsize length;
    -    while ((std::cin.read(buffer, 1024), length = std::cin.gcount()) > 0) {
    -        data.insert(data.end(), buffer, buffer + length);
    -    }
    -    return length == 0;
    -}
    -#endif
    -
    -#if defined(PROVIDE_FUZZ_MAIN_FUNCTION) && !defined(__AFL_LOOP)
    -static bool read_file(fs::path p, std::vector<uint8_t>& data)
    -{
    -    uint8_t buffer[1024];
    -    FILE* f = fsbridge::fopen(p, "rb");
    -    if (f == nullptr) return false;
    -    do {
    -        const size_t length = fread(buffer, sizeof(uint8_t), sizeof(buffer), f);
    -        if (ferror(f)) return false;
    -        data.insert(data.end(), buffer, buffer + length);
    -    } while (!feof(f));
    -    fclose(f);
    -    return true;
    -}
    -#endif
    -
    -#if defined(PROVIDE_FUZZ_MAIN_FUNCTION) && !defined(__AFL_LOOP)
    -static fs::path g_input_path;
    -[[noreturn]] void signal_handler(int signal)
    -{
    -    if (signal == SIGABRT) {
    -        std::cerr << "Error processing input " << g_input_path << std::endl;
    -    } else {
    -        std::cerr << "Unexpected signal " << signal << " received\n";
    -    }
    -    std::_Exit(EXIT_FAILURE);
    -}
    -#endif
    -
     // Whether or not these return depends on the build config.
     #if defined(__GNUC__)
     #pragma GCC diagnostic push
    @@ -214,13 +173,6 @@ static void initialize()
         ResetCoverageCounters();
     }
     
    -// This function is used by libFuzzer
    -extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
    -{
    -    test_one_input({data, size});
    -    return 0;
    -}
    -
     // This function is used by libFuzzer
     extern "C" int LLVMFuzzerInitialize(int* argc, char*** argv)
     {
    @@ -232,6 +184,54 @@ extern "C" int LLVMFuzzerInitialize(int* argc, char*** argv)
     #pragma GCC diagnostic pop
     #endif
     
    +#if defined(PROVIDE_FUZZ_MAIN_FUNCTION)
    +static bool read_stdin(std::vector<uint8_t>& data)
    +{
    +    std::istream::char_type buffer[1024];
    +    std::streamsize length;
    +    while ((std::cin.read(buffer, 1024), length = std::cin.gcount()) > 0) {
    +        data.insert(data.end(), buffer, buffer + length);
    +    }
    +    return length == 0;
    +}
    +#endif
    +
    +#if defined(PROVIDE_FUZZ_MAIN_FUNCTION) && !defined(__AFL_LOOP)
    +static bool read_file(fs::path p, std::vector<uint8_t>& data)
    +{
    +    uint8_t buffer[1024];
    +    FILE* f = fsbridge::fopen(p, "rb");
    +    if (f == nullptr) return false;
    +    do {
    +        const size_t length = fread(buffer, sizeof(uint8_t), sizeof(buffer), f);
    +        if (ferror(f)) return false;
    +        data.insert(data.end(), buffer, buffer + length);
    +    } while (!feof(f));
    +    fclose(f);
    +    return true;
    +}
    +#endif
    +
    +#if defined(PROVIDE_FUZZ_MAIN_FUNCTION) && !defined(__AFL_LOOP)
    +static fs::path g_input_path;
    +[[noreturn]] void signal_handler(int signal)
    +{
    +    if (signal == SIGABRT) {
    +        std::cerr << "Error processing input " << g_input_path << std::endl;
    +    } else {
    +        std::cerr << "Unexpected signal " << signal << " received\n";
    +    }
    +    std::_Exit(EXIT_FAILURE);
    +}
    +#endif
    +
    +// This function is used by libFuzzer
    +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
    +{
    +    test_one_input({data, size});
    +    return 0;
    +}
    +
     #if defined(PROVIDE_FUZZ_MAIN_FUNCTION)
     int main(int argc, char** argv)
     {
    
    

    </details>


    fanquake commented at 2:45 PM on November 23, 2026:

    Thanks, simplified this.

  84. in src/interfaces/init.h:51 in 53ab81e539 outdated
      47 | @@ -48,7 +48,7 @@ class Init
      48 |      virtual Ipc* ipc() { return nullptr; }
      49 |      virtual bool canListenIpc() { return false; }
      50 |      virtual const char* exeName() { return nullptr; }
      51 | -    virtual void makeMiningOld2() { throw std::runtime_error("Old mining interface (@2) not supported. Please update your client!"); }
      52 | +    [[noreturn]] virtual void makeMiningOld2() { throw std::runtime_error("Old mining interface (@2) not supported. Please update your client!"); }
    


    stickies-v commented at 1:29 PM on November 23, 2026:

    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?

  85. stickies-v approved
  86. stickies-v commented at 1:33 PM on November 23, 2026: contributor

    ACK 53ab81e5395fb3114bde3530791c44af05b923fb

  87. DrahtBot requested review from hebasto on Nov 23, 2026
  88. refactor: add missing [[noreturn]] attributes bc5a2386b7
  89. refactor: pragma around build-dependant missing noreturn 68068e1d7f
  90. build: add -Wmissing-noreturn to warning flags 98bca14fc7
  91. refactor: use C++ std::abort/exit over abort/exit() 1de12da093
  92. fanquake force-pushed on Nov 23, 2026
  93. stickies-v commented at 3:51 PM on November 23, 2026: contributor

    re-ACK 1de12da093a553376731aee7efdfad9b3357b8c5


github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-11-24 00:51 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me