mirror of
https://github.com/bitcoin/bitcoin
synced 2026-12-04 09:32:37 +00:00
WIP: [wip,nomerge,rfc] build: Require C++23 compiler #36033
No reviewers
Labels
No labels
Android
Backport
Block storage
Brainstorming
Bug
Build system
CI failed
Consensus
Data corruption
Descriptors
Docs
DrahtBot Guix build requested
Feature
Fuzzing
GUI
Good First Review
IPC
Insufficient Review
Kernel
Linux/Unix
Mempool
Mining
Needs Backport (31.x)
Needs Backport (32.x)
Needs Benchmark
Needs Conceptual Review
Needs backport (30.x)
Needs rebase
Needs release note
Net
P2P
PSBT
Privacy
Private Broadcast
Questions and Help
RPC/REST/ZMQ
Refactoring
Resource usage
Review club
Scripts and tools
Settings
TX fees and policy
Tests
Tracking Issue
UTXO Db and Indexes
Up for grabs
Upstream
Utils/log/libs
Validation
Waiting for author
Wallet
Windows
good first issue
interfaces
macOS
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
bitcoin/bitcoin!36033
Loading…
Reference in a new issue
No description provided.
Delete branch "2608-cpp23"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
C++23 for Bitcoin Core is mostly a "style update" on top of C++20. However, the workarounds to avoid C++23 keep accumulating and some parts of the code already use C++23 features, such as lambda attributes (
github.com/bitcoin-core/libmultiprocess@bdd0cd6941).I don't know when it is fine to switch, but at some point, I think it is fine to require a C++23 compiler, so that new stuff is unlocked. Of course this requires bumping the minimum required compiler versions:
There are some C++23 features that aren't implemented (such as
<stacktrace>not really shipped in any vanilla stdlib today), or e.g.ranges::starts_withnot implemented until libstdc++-16. But overall I think we are better off using C++23 without those few features instead of waiting longer?The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
External sites
Reviews
See the guideline and AI policy for information on the review process.
If your review is incorrectly listed, please copy-paste
<!--meta-tag:bot-skip-->into the comment that the bot should ignore.Conflicts
Reviewers, this pull request conflicts with the following ones:
InferScriptcreates invalid descriptors for invalid pubkeys by Eunovo)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.
🚧 At least one of the CI tasks failed.
Task
NetBSD Cross: https://github.com/bitcoin/bitcoin/actions/runs/32352184973/job/96373551351LLM reason (✨ experimental): CI failed due to a C++ build error:
std::ranges::views::zipis not available (no member named 'zip' in namespace 'std::ranges::views').Hints
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.
Concept ACK
edede385cab47020124bba6db98d69319168afb5
This looks like IWYU's "Automatic re-export: function return values" heuristics in action.
🐙 This pull request conflicts with the target branch and needs rebase.
🐙 This pull request conflicts with the target branch and needs rebase.
Review failed because required verification did not complete.
Earlier concerns neither republished nor resolved: 4 major findings · 1 minor finding · 4 suggestions. See the Run archive linked from the Review report for their assessments.
Review coverage was incomplete.
Reviewed:
4a926d33b6c5· Review report · Previous reportspermalink
🐙 This pull request conflicts with the target branch and needs rebase.
ralph referenced this pull request2026-10-07 09:09:34 +00:00
🐙 This pull request conflicts with the target branch and needs rebase.
🐙 This pull request conflicts with the target branch and needs rebase.
🐙 This pull request conflicts with the target branch and needs rebase.
🐙 This pull request conflicts with the target branch and needs rebase.
self-nit: Should `std::unreachable` be rejected? Here is a linter diff
My inline comments cover build and IPC compatibility, the skipped-path regression in block import, test guards for
expected, and optional C++23 cleanups.I have added patches to illustrate those suggestions, but I don't think we should fix them all here - but it would make sense to add a small compile sample for each to demonstrate support across our infrastructure - then handle the exhaustive call-site migrations in separate PRs.
GCC 12 and NetBSD's libstdc++ 12 fail on features this PR uses - maybe we could mention #36042 as a dependency.
Cap'n Proto 0.9.2 headers fail with GCC 14 and Apple Clang in C++23. The libmultiprocess compatibility check could be updated separately to cover C++23. Here, requiring Cap'n Proto 1.0 when IPC is enabled would cover bundled and external libmultiprocess builds.
Example patch
After the C++23 switch, network, RPC, tests, and the chainstate demo still cast enums through their underlying types.
std::to_underlyingexpresses those conversions directly.Example patch
transaction_identifier::FromHexand two descriptor counts can useoptional::transformafter C++23.TapSatisfier::FromPKHBytescan constructoptional<XOnlyPubKey>fromoptional<CPubKey>directly, and that cleanup could land earlier.Example patch
fold_leftcan take each fee vector directly with the existingCAmount{0}seed. This is a small optional cleanup.Example patch
The RISC-V link test still compiles and links its internal-header consumer as C++20. I'd update both flags to C++23 for this migration.
Example patch
Most hunks are ordinary C++20 cleanup and could land on master now. The
NUMS_Hlambda needs C++23, and the CMake probe should change to-std=c++23only with this PR.Example patch
The keypath and descriptor parsers build
string_views from both ends of existing character spans, and the descriptor test does the same. C++23 lets these four sites construct the view from the span directly.Example patch
The three
internal_bswapfunctions now only forward tostd::byteswap.Example patch
The zip loop reads a length before checking whether its path is null.
Example patch
The block-import loop needs indexed access because null paths need no corresponding length. Elsewhere, five loops use an index only to pair entries from related containers.
Example patch
strHelp.contains('\n')scans for the newline beforefindscans again. I would keep thefindposition, usecontainsfor the host-port colon and argsman error checks, and remove the redundant category-reset ternary (the newline and category changes can be pushed independently, the othercontainsedits need C++23).Example patch
The tests use
BOOST_CHECKbefore accessingerror()orvalue(), so a failed check continues into a wrong-state access. This is already true on master and can be fixed before thestd::expectedmigration.Example patch
We already compile the bundled libmultiprocess as C++23. Its standalone build still supports C++20, so changing those tests to
.contains()here would break it. Could the tidy job disable onlyreadability-container-containsfor the subtree?ContainsNULnow only callscontains('\0'), so I'd inline that check at its callers and remove the standalone fuzz call. The other membership searches can useranges::contains.loadwalletcan reuseGetWallettoo, and that part could land separately before the C++23 switch.Example patch
Sure, but then it should be done in all places? Ref: https://github.com/bitcoin/bitcoin/pull/36535#issuecomment-6186677574
Hmm, I don't know the answer here. See also https://github.com/bitcoin/bitcoin/issues/34928. One one hand it is nice to just run tidy on everything as a belt-and-suspender. On the other hand, it is extra effort ...
This happens with C++20 on current master, so it needs to be an independent pull.
This happens on master, and I don't think this needs to be fixed in tests. If it was, it should be checked and enforced by tidy, not manually.
See also my rant https://github.com/bitcoin/bitcoin/pull/35139, but I don't think it'll go anywhere.
ok, but this seems unrelated to C++23? Maybe a separate pull can be created?
Sure, this can be done right after merge of this one.
thx, took some and replied to the others
I mean this is a behavior change as-is
ok, I already dropped the commit in the last push. I guess using
views::zipisn't worth it in normal code. Only exception could be the univalue iteration, but this can be done later inside the univalue lib.Closing for now. Let's continue in https://github.com/bitcoin/bitcoin/pull/36747#discussion_r4711280131