Skip to content

[clang] Unnecessary instantiations of constexpr functions in if constexpr (false) #151113

@eisenwave

Description

@eisenwave
template <int N>
constexpr void f() {
    static_assert(N == 0);
}

void g() {
    if constexpr (false) {
        f<1>();
    }
}

This fails to compile: https://gcc.godbolt.org/z/G87rsPjWo (GCC accepts)

Removing constexpr from f() makes this compile, but it shouldn't matter either way. f() is not odr-used, not constant-evaluated, or otherwise needs to be instantiated.

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang:frontendLanguage frontend issues, e.g. anything involving "Sema"diverges-from:gccDoes the clang frontend diverge from gcc on this issuequestionA question, not bug report. Check out https://llvm.org/docs/GettingInvolved.html instead!

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions