Skip to content

refactor: add [[noreturn]] attributes - #339

Merged
ryanofsky merged 2 commits into
bitcoin-core:masterfrom
fanquake:missing_noreturn
Aug 12, 2026
Merged

refactor: add [[noreturn]] attributes#339
ryanofsky merged 2 commits into
bitcoin-core:masterfrom
fanquake:missing_noreturn

Conversation

@fanquake

Copy link
Copy Markdown
Member

These will be used downstream, see bitcoin/bitcoin#35911.

@DrahtBot

DrahtBot commented Aug 10, 2026

Copy link
Copy Markdown

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

Reviews

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

Type Reviewers
ACK hebasto

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

Comment thread include/mp/proxy-types.h
ReadField(
TypeList<LocalType>(), invoke_context, input, ReadDestEmplace(TypeList<LocalType>(),
[](auto&& ...args) -> const LocalType& { throw LocalType{std::forward<decltype(args)>(args)...}; }));
[] [[noreturn]] (auto&& ...args) -> const LocalType& { throw LocalType{std::forward<decltype(args)>(args)...}; }));

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In commit "refactor: add missing [[noreturn]] attributes" (82d5c4c)

It seems like this noreturn might not work because it requires c++23 lambda syntax. It is causing some CI jobs to fail with

/home/runner/work/libmultiprocess/libmultiprocess/include/mp/proxy-types.h:223:16: error: an attribute specifier sequence in this position is a C++23 extension [-Werror,-Wc++23-lambda-attributes]

https://github.com/bitcoin-core/libmultiprocess/actions/runs/31382467869/job/93435472734?pr=339#step:6:474

Comment thread include/mp/proxy-types.h
ReadField(
TypeList<LocalType>(), invoke_context, input, ReadDestEmplace(TypeList<LocalType>(),
[](auto&& ...args) -> const LocalType& { throw LocalType{std::forward<decltype(args)>(args)...}; }));
[] [[noreturn]] (auto&& ...args) -> const LocalType& { throw LocalType{std::forward<decltype(args)>(args)...}; }));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fanquake

Was this change prompted by the -Wmissing-noreturn compiler flag? If so, could you provide the exact build configuration (system, compiler, extra flags) used to reproduce the warning?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At least with Apple Clang and -Wmissing-noreturn:

export CXXFLAGS="-Wmissing-noreturn"
cmake -B build -G Ninja          
-- The CXX compiler identification is AppleClang 21.0.0.21000101
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
-- Found Threads: TRUE
-- Found ZLIB: /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib/libz.tbd (found version "1.2.12")
-- Performing Test HAVE_PTHREAD_GETNAME_NP
-- Performing Test HAVE_PTHREAD_GETNAME_NP - Success
-- Performing Test HAVE_PTHREAD_THREADID_NP
-- Performing Test HAVE_PTHREAD_THREADID_NP - Success
-- Performing Test HAVE_PTHREAD_GETTHREADID_NP
-- Performing Test HAVE_PTHREAD_GETTHREADID_NP - Failed
-- Configuring done (0.9s)
-- Generating done (0.0s)
-- Build files have been written to: /Users/michael/libmultiprocess/build
cmake --build build --clean-first
[1/1] Cleaning all built files...
Cleaning... 0 files.
[5/7] Building CXX object CMakeFiles/multiprocess.dir/src/mp/proxy.cpp.o
In file included from /Users/michael/libmultiprocess/src/mp/proxy.cpp:8:
/Users/michael/libmultiprocess/include/mp/proxy-types.h:223:13: warning: function 'operator()' could be declared with attribute 'noreturn' [-Wmissing-noreturn]
  223 |             [](auto&& ...args) -> const LocalType& { throw LocalType{std::forward<decltype(args)>(args)...}; }));
      |             ^
1 warning generated.
[7/7] Linking CXX static library libmultiprocess.a

@hebasto hebasto Aug 11, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It appears that the behavior of -Wmissing-noreturn depends on the Clang version:

$ env CXX="clang++-21" CXXFLAGS="-Wmissing-noreturn" cmake -B build_clang21
$ cmake --build build_clang21
[6/7] Building CXX object CMakeFiles/multiprocess.dir/src/mp/proxy.cpp.o
In file included from /home/hebasto/dev/libmultiprocess/src/mp/proxy.cpp:8:
/home/hebasto/dev/libmultiprocess/include/mp/proxy-types.h:223:13: warning: function 'operator()' could be declared with attribute 'noreturn' [-Wmissing-noreturn]
  223 |             [](auto&& ...args) -> const LocalType& { throw LocalType{std::forward<decltype(args)>(args)...}; }));
      |             ^
1 warning generated.
[7/7] Linking CXX static library libmultiprocess.a

However,

$ env CXX="clang++-22" CXXFLAGS="-Wmissing-noreturn" cmake -B build_clang22
$ cmake --build build_clang22
[7/7] Linking CXX static library libmultiprocess.a

Could this be a regression in Clang?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we can just turn off the -Wc++23-lambda-attributes error. It seems like it might be less practically useful than the -Wmissing-noreturn one.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this be a regression in Clang?

Not a regression, but a deliberate change: llvm/llvm-project@3baddbb.

Suppress `-Wc++23-lambda-attributes` warnings in effected jobs.
```bash
/libmultiprocess/include/mp/proxy-types.h:223:16: warning: an attribute specifier sequence in this position is a C++23 extension [-Wc++23-lambda-attributes]
  223 |             [] [[noreturn]] (auto&& ...args) -> const LocalType& { throw LocalType{std::forward<decltype(args)>(args)...}; }));
      |                ^
1 warning generated.
```

@hebasto hebasto left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK a779a09.

@ryanofsky
ryanofsky merged commit bdd0cd6 into bitcoin-core:master Aug 12, 2026
13 checks passed
@fanquake
fanquake deleted the missing_noreturn branch August 12, 2026 13:01
@ryanofsky

ryanofsky commented Aug 12, 2026

Copy link
Copy Markdown
Collaborator

It looks like we will also need to add -Wno-c++23-lambda-attributes to the bitcoin build after the next libmultiprocess subtree update. Implemented in ryanofsky/bitcoin@c8aef32

EDIT: That commit doesn't work for older versions of clang or for MSVC. Updated version is ryanofsky/bitcoin@fd7da34

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants