Skip to content

[Clang] Implementation of P2280R4 caused worse diagnostic messages #157082

@frederick-vs-ja

Description

@frederick-vs-ja

constexpr int &n = n; // expected-error {{constant expression}} cxx23-note {{reference to 'n' is not a constant expression}} cxx23-note {{address of non-static constexpr variable 'n' may differ}} expected-warning {{not yet bound to a value}}
// cxx11_20-note@-1 {{use of reference outside its lifetime is not allowed in a constant expression}}

This looks strange. The old message looks better (see also CWG453) and the new one is possibly misleading as we perhaps shouldn't say the address of a reference variable.

Originally posted by @frederick-vs-ja in #95474 (comment)

This is still reproducible on the trunk. Godbolt link.

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang:diagnosticsNew/improved warning or error message in Clang, but not in clang-tidy or static analyzerconstexprAnything related to constant evaluation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions