[LLVMbugs] [Bug 24016] New: Incorrect error message when trying to modify a const reference in lambda
    bugzilla-daemon at llvm.org 
    bugzilla-daemon at llvm.org
       
    Thu Jul  2 02:30:09 PDT 2015
    
    
  
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: unassignedclangbugs at nondot.org
          Reporter: fynjycfdby at gmail.com
                CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
    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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20150702/f7113b8e/attachment.html>
    
    
More information about the llvm-bugs
mailing list