Skip to content

[Clang] Accepts invalid lambda init-capture shadowing a template parameter #126392

Open
@MagentaTreehouse

Description

@MagentaTreehouse

In the following code, the init-capture of the lambda has the same name as the NTTP i, which should not be allowed.

template <int i>
int f() {
    return [i = 0] { return i; }();
}

int i = f<0>();

This is diagnosed by GCC and EDG.

See https://compiler-explorer.com/z/oh7MhabG9.

Metadata

Metadata

Assignees

No one assigned

    Labels

    accepts-invalidclang:frontendLanguage frontend issues, e.g. anything involving "Sema"diverges-from:edgDoes the clang frontend diverge from edg compilerdiverges-from:gccDoes the clang frontend diverge from gcc on this issuelambdaC++11 lambda expressions

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions