[LLVMbugs] [Bug 19139] New: explain why a variable is const

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Thu Mar 13 20:00:02 PDT 2014


http://llvm.org/bugs/show_bug.cgi?id=19139

            Bug ID: 19139
           Summary: explain why a variable is const
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: nlewycky at google.com
                CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
    Classification: Unclassified

Clang should explain why a variable is read-only.

nlewycky at ducttape:~$ cat c.cc
const int k = 1;
void f() { k = 0; }
class X {
  int i;
  const int j = 1;
  void f() const { i = 0; }
  void g() { j = 0; }
};

nlewycky at ducttape:~$ llvm/Debug+Asserts/bin/clang c.cc -std=c++11
c.cc:2:14: error: read-only variable is not assignable
void f() { k = 0; }
           ~ ^
c.cc:6:22: error: read-only variable is not assignable
  void f() const { i = 0; }
                   ~ ^
c.cc:7:16: error: read-only variable is not assignable
  void g() { j = 0; }
             ~ ^
3 errors generated.

There are const's to point to in each of those cases.

-- 
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/20140314/2ce16a67/attachment.html>


More information about the llvm-bugs mailing list