Skip to content

False positive for cppcoreguidelines-init-variables in range based for loop in template function #44091

@pgerell

Description

@pgerell
Bugzilla Link 44746
Resolution FIXED
Resolved on Feb 10, 2020 05:20
Version unspecified
OS Linux
Blocks #43900
CC @zmodem,@pgerell
Fixed by commit(s) efcd09c

Extended Description

clang-tidy-10 as of 2020-01-31 gives the following false positive

====== test.cpp ======
template
void f(RANGE r) {
for (char c : r) {

}
}

$ clang-tidy test.cpp --checks='cppcoreguidelines*'
test.cpp:3:13: warning: variable 'c' is not initialized [cppcoreguidelines-init-variables]
for (char c : r) {
^
= 0

Also reproducible on trunk:
https://godbolt.org/z/s_bCSi

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions