llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
29.39k stars 12.15k forks source link

cppcoreguidelines-pro-type-member-init does not understand std::fill_n, std::array::fill #32029

Open LebedevRI opened 7 years ago

LebedevRI commented 7 years ago
Bugzilla Link 32682
Version unspecified
OS Linux

Extended Description

include

class a { char b[4]; std::array<char, 4> c;

a() { std::fill_n(b, 4, 0); c.fill(0); } };

$ clang-tidy -checks=* /tmp/test.cpp -- -std=c++11 2440 warnings generated. /tmp/test.cpp:7:3: warning: constructor does not initialize these fields: b, c [cppcoreguidelines-pro-type-member-init] a() { ^ /tmp/test.cpp:8:17: warning: do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay] std::fill_n(b, 4, 0); ^ Suppressed 2437 warnings (2437 in non-user code). Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.

I would say it should not complain here.

LebedevRI commented 7 years ago

(this is llvm/clang/clang-tidy from trunk)