Skip to content

Call to consteval function in member initializer cause compilation error #118000

@finomen

Description

@finomen

If consteval function called in method initializer and this class used in both consteval and not consteval functions, compilation fails with

<source>:4:17: error: cannot take address of consteval function 'baz' outside of an immediate invocation
    int mSize = baz();
consteval int baz() { return 0;}

struct S {
    int mSize = baz();
};

consteval void bar() {
    S s;
}

void foo() {
    S s;
}

This bug is present in 16.x.x and >=18.0.0. (https://godbolt.org/z/o6EnWvvW7)

Issue was introduced in ca61961
After it was fixed in 4676885
And happens again after baf6bd3

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang:frontendLanguage frontend issues, e.g. anything involving "Sema"confirmedVerified by a second partyconstevalC++20 consteval

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions