[llvm-bugs] [Bug 26896] New: no warning when calling anonymous variable's member

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Mar 10 03:03:09 PST 2016


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

            Bug ID: 26896
           Summary: no warning when calling anonymous variable's member
           Product: clang
           Version: unspecified
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: egmkang at outlook.com
                CC: dgregor at apple.com, llvm-bugs at lists.llvm.org
    Classification: Unclassified

consider give me a warning when i call `anonymous variable`'s member.
for such codes, i missed a `&`, the program maybe coredump.

#include <vector>
#include <iostream>

static std::vector<int> v;

const std::vector<int>/*&*/ get() { //i missed & here
  return v;
}

int main() {
  v.push_back(1);
  v.push_back(2);
  v.push_back(3);

  for (std::vector<int>::const_iterator iter = get().begin();
       iter != get().end(); ++iter) {
    std::cout << *iter << std::endl;
  }
  return 0;
}

-- 
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/20160310/db4e202c/attachment.html>


More information about the llvm-bugs mailing list