Skip to content

[Clang][C23] Possible bug in initialization of constexpr variable #115845

Open
@chestnykh

Description

@chestnykh

Consider the following code

void f(){}

const int x = 4;

constexpr auto a = x - x; //clang: error: constexpr variable 'a' must be initialized by a constant expression
constexpr auto b = &f - &f; // clang accepts

but trunk gcc rejects both constexpr variables with the same diagnostic

error: ‘constexpr’ integer initializer is not an integer constant expression

So i guess that clang should also reject the initialization of the 2nd constexpr variable

Metadata

Metadata

Assignees

No one assigned

    Labels

    c23clang:frontendLanguage frontend issues, e.g. anything involving "Sema"

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions