Open
Description
Bugzilla Link | 31461 |
Version | trunk |
OS | Linux |
Reporter | LLVM Bugzilla Contributor |
CC | @DougGregor,@nico,@zygoloid |
Extended Description
Consider the following
#include <memory>
struct A {};
struct B : public A {};
std::unique_ptr<A> f() {
auto result = std::unique_ptr<B>(new B);
return result;
}
In C++11, the return line has to have an std::move
, since the type of |result| doesn't match the return type of the function.
However, it compiles with current clang++
Expected:
$ clang++ -std=c++11 -c test.cpp
test.cpp:8:10: error: no viable conversion from 'unique_ptr<struct B, default_delete<struct B>>' to 'unique_ptr<struct A, default_delete<struct A>>'
return result;
^~~~~~
...
$ clang++ --version
clang version 3.9.0 (trunk 273760)
...
Actual:
$ clang++ -std=c++11 -c test.cpp
$ clang++ --version
clang version 3.9.0 (trunk 274367)
...
Since C++14 does allow this to compile, I suspect that http://reviews.llvm.org/D21619 inadvertently caused this.