为什么clang ++警告“建议围绕子对象初始化[-Wmissing-braces]”?

时间:2015-07-22 06:35:55

标签: clang++

我有这段代码:

#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};
                           ^~~~~
                           {    }

2 个答案:

答案 0 :(得分:18)

答案 1 :(得分:16)