A bug in the version of clang shipped with Xcode 8.x causes the following valid code to fail compilation:
struct Foo { virtual ~Foo() = default; };
struct Bar : public Foo { void Init(); };
std::unique_ptr<Foo> CreateFoo() {
std::unique_ptr<Bar> bar(new Bar);
bar->Init();
return bar;
}
The workaround is to change the code to the following:
std::unique_ptr<Foo> CreateFoo() {
std::unique_ptr<Bar> bar(new Bar);
bar->Init();
return std::move(bar);
}
However, it is discouraged to use an explicit "std::move()" for the returned value as it may cause the compiler to disable Return Value Optimisation (RVO). Remove that pattern once Chrome on iOS requires Xcode version with a fixed clang.
Comment 1 by bugdroid1@chromium.org
, Mar 21 2017