Skip to content

[clang-tidy] cppcoreguidelines-pro-type-member-init check flags local variables of std::array<> type #169677

@avaneyev

Description

@avaneyev

cppcoreguidelines-pro-type-member-init flags local std::array<> variables as uninitialized. This seems wrong, as these aren't members of a structure or class, where the check should be applied.
Setting the IgnoreArrays config parameter to true does not help. Not sure if this case was supposed to be covered by the IgnoreArrays param in the first place, or this is just a bug.

Example program:

include <array>

void func() {
    std::array<char, 10> someArray;
    someArray.fill('n');
}

which produces the following warning and a fix suggestion:

<source>:4:5: warning: uninitialized record type: 'someArray' [cppcoreguidelines-pro-type-member-init]
    4 |     std::array<char, 10> someArray;
      |     ^                             
      |                                   {}
1 warning generated.

(on godbolt: https://godbolt.org/z/rY9zPv7hG).

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions