Enable C++26 P3471 “Standard Library Hardening” ahead of time? #32265

issue maflcko openend this issue on April 14, 2025
  1. maflcko commented at 11:10 am on April 14, 2025: member

    C++26 includes standard library hardening (P3471). Albeit Bitcoin Core uses C++20 as of https://github.com/bitcoin/bitcoin/blob/51166559808c3528f148b5c0c38cb4481e536dd8/CMakeLists.txt#L74, the feature can be enabled in earlier versions of C++, according to https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2025/p3471r4.html#enabling-hardening. So the question is whether it should be done.

    Some benefits would be:

    • Less unsafe code, when preconditions are enforced by the standard library. This can help to find bugs, such as #32122.
    • Less manual precondition checking, which is verbose and sometimes wrong. For example, see #32255 (comment).

    The downsides would be:

    For now this is a brainstorming issue, to gather any benefits, downsides or questions that I’ve missed.

  2. maflcko added the label Brainstorming on Apr 14, 2025
  3. maflcko added the label Build system on Apr 14, 2025

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: 2025-04-16 15:12 UTC

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