llvm / llvm-project

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

clang-tidy check cppcoreguidelines-init-variables fails in some cases #47166

Open wp-seth opened 4 years ago

wp-seth commented 4 years ago
Bugzilla Link 47822
Version unspecified
OS Linux

Extended Description

i guess, i found three different types of false positives for the check 'cppcoreguidelines-init-variables':

.../ctor_test.cc:21:31: warning: variable 'vec' is not initialized [cppcoreguidelines-init-variables]
        abc::core::Vector<double, 2> vec = abc::core::Vector<double, 2>::zeros();
                                     ^
                                         = 0

.../ctor_test.cc:44:31: warning: variable 'vec' is not initialized [cppcoreguidelines-init-variables]
        abc::core::Vector<double, 2> vec(ary2);
                                     ^
                                         = 0

.../ops_test.cc:57:31: warning: variable 'vec' is not initialized [cppcoreguidelines-init-variables]
        abc::core::Vector<double, 3> vec{1., 1., 1.};
                                     ^
                                         = 0

i used the command: clang-tidy -header-filter='.*' -checks='*,-cppcoreguidelines-pro-bounds-pointer-arithmetic,-fuchsia-default-arguments-calls,-fuchsia-default-arguments-declarations,-fuchsia-virtual-inheritance,-fuchsia-overloaded-operator,-fuchsia-multiple-inheritance,-google-runtime-references,-modernize-use-trailing-return-type' 'dir/ctor_test.cc' -- -x c++ -Wno-c++98-compat -Wno-c++-compat -std=c++11 -I include

(edit: re-formatted after transfer from bugzilla)

PiotrZSL commented 1 year ago

This is most probably caused by compilation error.