llvm / llvm-project

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

fuchsia-default-arguments-calls warns on STL containers' constructors #55060

Open junaire opened 2 years ago

junaire commented 2 years ago

I'm not sure if this is by design, but I think it really confuses me.

#include <vector>

int main()
{
    std::vector<int> vec {1,2,3,4};
}

Runs:

clang-tidy --checks='fuchsia-default-arguments-calls' fuchsia.cc

Warns:

/tmp/fuchsia.cc:5:28: warning: calling a function that uses a default argument is disallowed [fuchsia-default-arguments-calls]
    std::vector<int> vec = {1,2,3,4};
                           ^
/usr/lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/bits/stl_vector.h:626:7: note: default parameter was declared here
             const allocator_type& __a = allocator_type())

Please check out https://godbolt.org/z/577Ga1Wbc

llvmbot commented 2 years ago

@llvm/issue-subscribers-clang-tidy

junaire commented 2 years ago

IMHO, we should at least skip standard containers' constructors.