Skip to content

suggest std::move #19965

@llvmbot

Description

@llvmbot
Bugzilla Link 19591
Version trunk
OS All
Reporter LLVM Bugzilla Contributor
CC @DougGregor,@zygoloid

Extended Description

$ cat a.cc
#include <memory>

void f(std::unique_ptr<int> i) {
  std::unique_ptr<int> j = i;
}
$ clang a.cc -std=c++11
a.cc:4:24: error: call to deleted constructor of 'std::unique_ptr<int>'
  std::unique_ptr<int> j = i;
                       ^   ~
/usr/lib/gcc/x86_64-linux-gnu/4.6/../../../../include/c++/4.6/bits/unique_ptr.h:256:7: note: 
      'unique_ptr' has been explicitly marked deleted here
      unique_ptr(const unique_ptr&) = delete;
      ^
1 error generated.

Could we detect that there is a rvalue-reference constructor and suggest that the user may have wanted to use it (or std::move)?

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugzillaIssues migrated from bugzillac++11clang:diagnosticsNew/improved warning or error message in Clang, but not in clang-tidy or static analyzer

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions