False positive cppcoreguidelines-pro-type-member-init for array and std::fill
Seems like a regression in clang-19:
#include <algorithm>
#include <iterator>
struct S {
char a[100];
S() {
std::fill(std::begin(a), std::end(a), '\0');
}
};
<source>:6:2: warning: constructor does not initialize these fields: a [cppcoreguidelines-pro-type-member-init]
5 | char a[100];
|
| {}
6 | S() {
| ^
https://godbolt.org/z/6WfzWGYr9
@llvm/issue-subscribers-clang-tidy
Author: None (chrchr-github)
struct S { char a[100]; S() { std::fill(std::begin(a), std::end(a), '\0'); } };
<source>:6:2: warning: constructor does not initialize these fields: a [cppcoreguidelines-pro-type-member-init]
5 | char a[100];
|
| {}
6 | S() {
| ^
https://godbolt.org/z/6WfzWGYr9
</details>
Reduced:
#include <algorithm>
struct S {
char a[100];
S() {
std::fill(a, a + 100, '\0');
}
};
According to the docs:
The check takes assignment of fields in the constructor body into account but generates false positives for fields initialized in methods invoked in the constructor body.
Looks like this is the intended behaviour for now in this kind of methods. this is still a very poor check IMO, hope it gets fixed in the future.