Skip to content

Bundled Clang rejects pre() on a declaration, so a corpus using C++26 contracts cannot be extracted #1307

Description

@mpusz

mp-units expresses preconditions as pre() on the declaration when contracts are available (P2900, C++26), guarded on __cpp_contracts >= 202502L. The bundled Clang rejects them.

Reproduced with MrDocs 2026.9.4 (LLVM 23.0.0git) on a declaration equivalent to:

[[nodiscard]] constexpr const_reference operator[](size_type pos) const pre(pos < N);

With -std=c++26, and again with -std=c++2c -fcontracts, both fail identically with expected ';' at end of declaration list followed by cascading use of undeclared identifier errors, and the corpus comes out empty (0 pages). Passing -fcontracts made no difference to the diagnostics.

So today we have to generate the reference with contracts switched off, which is a pity, because the contracts are the part of the interface a reader most wants to see.

Questions: is P2900 support in the bundled toolchain on the roadmap, and in the meantime is there a way to have the parser skip a contract annotation rather than fail the translation unit?

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    featNew capability or enhancement

    Type

    No type

    Projects

    • Status
      No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions