为什么 clang++ 警告 "suggest braces around initialization of subobject [-Wmissing-braces]"?

Why is clang++ warning "suggest braces around initialization of subobject [-Wmissing-braces]"?

我有这个代码:

#include <array>

int main(int, char **argv)
{
   std::array<int, 3> a = {1,2,3};
}

这个编译很好 (-std=c++11) ,但是如果你包含 -Wall 它会给出这个我不明白的警告:

clang_pp_error.cpp:5:28: warning: suggest braces around initialization of subobject [-Wmissing-braces]
   std::array<int, 3> a = {1,2,3};
                           ^~~~~
                           {    }

这应该是一个错误:https://llvm.org/bugs/show_bug.cgi?id=21629

另见 Is it wise to ignore gcc/clang's "-Wmissing-braces" warning?

改用std::array<int, 3> a = {{1,2,3}};

Why wasn't a double curly braces syntax preferred for constructors taking a std::initializer_list