[llvm-bugs] [Bug 39963] New: Structured binding declaration & closure does not work

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Dec 11 11:52:59 PST 2018


            Bug ID: 39963
           Summary: Structured binding declaration & closure does not work
           Product: clang
           Version: 7.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++'17
          Assignee: unassignedclangbugs at nondot.org
          Reporter: bugs.llvm.org-jfkdshfj at exyi.cz
                CC: blitzrakete at gmail.com, erik.pilkington at gmail.com,
                    llvm-bugs at lists.llvm.org, richard-llvm at metafoo.co.uk

The following code does not compile:


void a() {
    const auto [t, i] = std::pair{1, 2};
    ([i](){ return i; })();
int main() {}

When I remove the pair "deconstruction" and declare the variable traditionally
it works. When I don't use the variable in lambda closure, it works. When I
compile with gcc, it works. Clang says:

database/aggregator.cpp:5:7: error: 'i' in capture list does not name a
    ([i](){ return i; })();
database/aggregator.cpp:5:20: error: reference to local binding 'i' declared in
enclosing function 'a'
    ([i](){ return i; })();
database/aggregator.cpp:4:20: note: 'i' declared here
    const auto [t, i] = std::pair{1, 2};
2 errors generated.

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/20181211/c34b2ed9/attachment.html>

More information about the llvm-bugs mailing list