[llvm-bugs] [Bug 31234] New: Should immediately reading from a consumed object provoke a warning?
via llvm-bugs
llvm-bugs at lists.llvm.org
Thu Dec 1 23:05:29 PST 2016
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: unassignedclangbugs at nondot.org
Reporter: jacquelinekay1 at gmail.com
CC: dgregor at apple.com, llvm-bugs at 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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20161202/4a957f8d/attachment-0001.html>
More information about the llvm-bugs
mailing list