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

            Bug ID: 24016
           Summary: Incorrect error message when trying to modify a const
                    reference in lambda
           Product: clang
           Version: 3.6
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++11
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected], [email protected]
    Classification: Unclassified

This code:

int main() {
    int x = 0;
    const int& rx = x;
    auto l = [&rx]() {
        rx = 5;
    };
}


produces error message:

test.cpp:5:12: error: cannot assign to a variable captured by copy in a
non-mutable lambda
        rx = 5;
        ~~ ^

Moreover, even this code:

int main() {
    int x = 0;
    const int& rx = x;
    auto l = [&rx]() mutable {
        rx = 5;
    };
}

produces the same error message.


But the message should rather say that modifying const reference is not
allowed.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs

Reply via email to