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

            Bug ID: 41165
           Summary: invalid error: reference to local variable 'xxx'
                    declared in enclosing lambda
           Product: clang
           Version: 7.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++'17
          Assignee: unassignedclangb...@nondot.org
          Reporter: jonathan.poe...@gmail.com
                CC: blitzrak...@gmail.com, erik.pilking...@gmail.com,
                    llvm-bugs@lists.llvm.org, richard-l...@metafoo.co.uk

template<class... Ts>
void foo(Ts... xs)
{
    [&](auto&... lhs){
        [&](auto&... rhs){
            ((lhs = rhs), ...);
        }(xs...);
    }(xs...);
}

int main()
{
  foo(1);
}


test.cpp:6:15: error: reference to local variable 'lhs' declared in enclosing
lambda expression
            ((lhs = rhs), ...);
              ^


If lhs is captured explicitly, there is no error, but a warning:

test.cpp:5:11: warning: lambda capture 'lhs' is not used
[-Wunused-lambda-capture]
        [&lhs...](auto&... rhs){
          ^

(Works with GCC and MSVC)

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to