[llvm-bugs] [Bug 25911] New: -Wpessimizing-move doesn't trigger inside template instantiations
via llvm-bugs
llvm-bugs at lists.llvm.org
Mon Dec 21 12:05:33 PST 2015
https://llvm.org/bugs/show_bug.cgi?id=25911
Bug ID: 25911
Summary: -Wpessimizing-move doesn't trigger inside template
instantiations
Product: clang
Version: unspecified
Hardware: PC
OS: Windows NT
Status: NEW
Severity: normal
Priority: P
Component: C++11
Assignee: unassignedclangbugs at nondot.org
Reporter: dcheng at google.com
CC: dgregor at apple.com, llvm-bugs at lists.llvm.org
Classification: Unclassified
https://llvm.org/bugs/show_bug.cgi?id=9679 is a bug that indicates that it's
generally unsafe to emit fix-its inside template instantiations.
However, this leads to omission of a pessimizing-move warning in some
circumstances where it could apply. One example:
dcheng at nausicaa:~/src/chrome/src$ cat test.cc
#include <utility>
template<typename T>
class my_scoped_ptr {
public:
explicit my_scoped_ptr(T* ptr) : ptr_(ptr) {}
~my_scoped_ptr() { delete ptr_; }
my_scoped_ptr(my_scoped_ptr&& other) : ptr_(nullptr) {
using std::swap;
swap(ptr_, other.ptr_);
}
static my_scoped_ptr New() { return std::move(my_scoped_ptr(nullptr)); }
private:
T* ptr_;
};
int main() {
my_scoped_ptr<int> scoper = my_scoped_ptr<int>::New();
}
dcheng at nausicaa:~/src/chrome/src$
third_party/llvm-build/Release+Asserts/bin/clang++ -std=c++11 -W
all test.cc
dcheng at nausicaa:~/src/chrome/src$
--
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/20151221/6184a68b/attachment.html>
More information about the llvm-bugs
mailing list