Skip to content

[Clang] -Winvalid-constexpr misbehaves in C++23 mode #149041

@frederick-vs-ja

Description

@frederick-vs-ja

In C++23/26 mode, Clang rejects the following function definition with -Winvalid-constexpr used, saying "constexpr function never produces a constant expression". Godbolt link.

constexpr bool fun(const bool& b) { return b; }

This seems related to P2280R4, but the incorrect diagnostic occurs only since Clang 21.

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang:frontendLanguage frontend issues, e.g. anything involving "Sema"constexprAnything related to constant evaluationregressionrejects-valid

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions