Skip to content

clang 13 to trunk accepts implicit move of parameters in C++17 and no feature flag set #122645

@beached

Description

@beached

The following code is not an error in clang but isn't valid to my knowledge.

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang:frontendLanguage frontend issues, e.g. anything involving "Sema"

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions