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

            Bug ID: 31234
           Summary: Should immediately reading from a consumed object
                    provoke a warning?
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++11
          Assignee: unassignedclangb...@nondot.org
          Reporter: jacquelinek...@gmail.com
                CC: dgre...@apple.com, llvm-bugs@lists.llvm.org
    Classification: Unclassified

The following example does not provoke a warning in clang or clang-tidy
(trunk). It also does not produce an error in UBSan.


#include <iostream>
#include <utility>
#include <vector>

int main(int, char**) {
  std::string a("hello");
  std::vector<std::string> x;
  x.emplace_back(std::move(a));

  if (a == "hello") {
    std::cout << "a retains original value" << std::endl;
  }

  return 0;
}


I would expect there to be a tool in the Clang/LLVM family to help detect this
kind of bug (side effects which depend on a read from a moved-from object).
However, I am not sure where this error should be detected: should it be a
compiler warning, a static analysis tool diagnostic, or a sanitizer error?

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to