Skip to content

[Clang] Regression on not rejecting UB in constexpr reference initialization due to implementing P2280R4 #131330

@frederick-vs-ja

Description

@frederick-vs-ja

Currently, Clang accepts the following code snippet since C++23 mode. Godbolt link.

constexpr int& r = r;

[dcl.ref]/6 (as clarified by the resolution of CWG453) indicates that such reference binding has UB, and thus needs to be rejected in constant evaluation.

Perhaps this is due to something missed in #95474.

Codegen change can be observed by dropping constexpr (Godbolt link), but this is conforming as such initialization raises UB.

Metadata

Metadata

Assignees

No one assigned

    Labels

    accepts-invalidclang:frontendLanguage frontend issues, e.g. anything involving "Sema"constexprAnything related to constant evaluation

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions