llvm / llvm/llvm-project

modernize-use-ranges false positive for std::fill on std::vector<bool>

Open
#195,296 3 comments 0 reactions 1 assignee Claimed by @Supercool1604 View on GitHub
clang-tidy false-positive invalid-code-generation
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

clang-tidy version 22.1.3 for C++20 recommends to use a ranges algorithm to fill a `std::vector`:

```
#include

int main() {
std::vector v(10);

// Fill the entire range with true
std::fill(v.begin(), v.end(), true); // warning: use a ranges version of this algorithm [modernize-use-ranges]
}
```

The `std::ranges::fill` algorithm, however, cannot be used with `std::vector` in C++20.

https://godbolt.org/z/evj8r8azW

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.