Skip to content

[clang] Immediate invocations in constexpr initailizers are evaluated twice #117321

Open
@groundswellaudio

Description

@groundswellaudio

It seems that immediate invocations in constexpr initailizers are evaluated twice, once on evaluating the decl, and again on Sema::HandleImmediateInvocations (this doesn't happen if the var is within a consteval function). Strictly speaking, not a defect, but it's kinda wasteful?

consteval int foo(int* b) {
    return *b; // Evaluation errors are emitted twice
}

constexpr int a = foo(nullptr); 

https://godbolt.org/z/7ec5bsK9e

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions