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
    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;

  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

Reply via email to