Skip to content

lambda: immediate function 'operator()<int>' used before it is defined #117676

Open
@Fedr

Description

@Fedr

This C++23 program

#include <memory>

consteval auto func1() {
    return std::make_unique<int>();
}

template <typename T>
consteval void func2() {
    [](auto) -> void {
        func1();
    }(0);
}

int main() {
    func2<int>();
}

is accepted by GCC, but Clang prints weird error:

error: immediate function 'operator()<int>' used before it is defined
    9 |     [](auto) -> void {

Online demo: https://gcc.godbolt.org/z/Kb8M7c3nb

Original discussion: https://stackoverflow.com/q/79221393/7325599

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang:frontendLanguage frontend issues, e.g. anything involving "Sema"confirmedVerified by a second partyconstevalC++20 constevallambdaC++11 lambda expressionsrejects-valid

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions