Issue 122645
Summary clang 13 to trunk accepts implicit move of parameters in C++17 and not feature flag
Labels clang
Assignees
Reporter beached
    The following code is not an error in clang but isn't valid to my knowledge.

```cpp
template <typename Pointer, typename F>
constexpr auto or_else(Pointer &&p, F &&f) -> remove_cvref_t<Pointer> {
    if (not p) {
 return FWD(f)( );
    }
    return std::move( p );  // not needed in clang 13+
}

std::unique_ptr<int> foo(std::unique_ptr<int> p) {
 return or_else(std::move(p), [] { return std::make_unique<int>(42); });
}
```

https://gcc.godbolt.org/z/TzWf6Eqov

The move on p isn't required as of clang-13 while compiled with `-std=c++17 -pedantic -pedantic-errors`.  The macro `__cpp_implicit_move` isn't defined either.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to