llvm / llvm/llvm-project

[libc++] deque::prepend_range rejects some valid code

Open
#162,605 2 comments 0 reactions 0 assignees View on GitHub
libc++ rejects-valid
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

```c++
struct InPlaceOnly {
constexpr InPlaceOnly() {}
InPlaceOnly(const InPlaceOnly&) = delete;
InPlaceOnly(InPlaceOnly&&) = delete;
InPlaceOnly& operator=(const InPlaceOnly&) = delete;
InPlaceOnly& operator=(InPlaceOnly&&) = delete;
};

struct EmplaceConstructible {
EmplaceConstructible(const EmplaceConstructible&) = delete;
EmplaceConstructible& operator=(const EmplaceConstructible&) = delete;
EmplaceConstructible& operator=(EmplaceConstructible&&) = delete;
EmplaceConstructible(EmplaceConstructible&&) = delete;
constexpr EmplaceConstructible(const InPlaceOnly&) {}
};

template class Container>
constexpr void test_sequence_prepend_range_emplace_constructible() {
InPlaceOnly input[5];
types::for_each(types::cpp20_input_iterator_list{}, [&] {
std::ranges::subrange in(Iter(input), sentinel_wrapper(Iter(input + 5)));
Container c;
c.prepend_range(in);
});
}
```
This code is correct, but currently rejected by our `deque::prepend_range` implementation.

Contributor guide

Open the contributing guide

Research direction

Start with the libc++ implementation of deque::prepend_range and reproduce the rejection using the provided InPlaceOnly and EmplaceConstructible example with the input-iterator variants. Trace how the range elements are constructed, then verify that this valid code is accepted without breaking existing prepend_range behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.