[llvm-bugs] [Bug 51986] New: Redefinition of variable in lambda when also defined in external init-statement, regardless of capture

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Sep 27 10:33:20 PDT 2021


https://bugs.llvm.org/show_bug.cgi?id=51986

            Bug ID: 51986
           Summary: Redefinition of variable in lambda when also defined
                    in external init-statement, regardless of capture
           Product: clang
           Version: unspecified
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: llvm at rifkin.dev
                CC: htmldeveloper at gmail.com, llvm-bugs at lists.llvm.org,
                    neeilans at live.com, richard-llvm at metafoo.co.uk

When a lambda is used in a `condition`, whether IILE or as an argument to
another function, and defines a variable with the same name as a variable
defined in the statement's `init-statement`, clang erroneously errors that
there is a redefinition

void foo() {
    int i = 0;
    [] { // fine
        int i = 1;
        return I;
    } ();
}

void bar() {
    for(
        int i = 0;
        [] { // not fine
            int i = 1;
            return i;
        } ();
    ) { ... }
}

The same happens with if and switch statements, and only happens when the
variable outside is defined in an init statement.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20210927/b1f5d54f/attachment.html>


More information about the llvm-bugs mailing list