Skip to content

copy_if test seem to violate the precondition #139464

Open
@AlexGuteniev

Description

@AlexGuteniev

[alg.copy]/16:

Preconditions: The ranges [first, last) and [result, result + (last - first)) do not overlap.

The following test do not have this precondition satisfied, as it doesn't even have [result, result + (last - first)) range:

std::array<S, 4> in = {{{4, 2}, {1, 3}, {3, 4}, {3, 5}}};
std::array<S, 2> out;
auto ret = std::ranges::copy_if(in.begin(), in.end(), out.begin(), [](int i) { return i == 3; }, &S::val);

The following tests seem to be also affected by similar issue:

  • std/algorithms/alg.modifying.operations/alg.remove/ranges_remove_copy.pass.cpp
  • std/algorithms/alg.modifying.operations/alg.unique/unique_copy.pass.cpp
  • std/algorithms/alg.modifying.operations/alg.unique/ranges_unique_copy.pass.cpp

Metadata

Metadata

Assignees

No one assigned

    Labels

    libc++libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.test-suite

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions