[llvm-bugs] [Bug 27562] New: Warn if a value that's been std::move()d from is accessed

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Apr 28 11:39:34 PDT 2016


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

            Bug ID: 27562
           Summary: Warn if a value that's been std::move()d from is
                    accessed
           Product: clang
           Version: unspecified
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: nicolasweber at gmx.de
                CC: dgregor at apple.com, llvm-bugs at lists.llvm.org
    Classification: Unclassified

Spot the bug:

  auto insertion_result = allocator_dumps_.insert(
      std::make_pair(mad->absolute_name(), std::move(mad)));
  DCHECK(insertion_result.second) << "Duplicate name: " <<
mad->absolute_name();     


mad is move()d from in the first statement but then accessed in the second.
This is probably almost always a bug. We should warn on it. (I couldn't find an
existing bug for this.)

Maybe this could work similar to -Wuninitialized where we conceptually treat
things that have been move()d from as uninitialized from that point on.

-- 
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/20160428/d18ceed1/attachment.html>


More information about the llvm-bugs mailing list