I have this code:
#include <array>
int main(int, char **argv)
{
std::array<int, 3> a = {1,2,3};
}
This compiles fine (-std=c++11) , but if you include -Wall it gives this warning that I don't understand:
clang_pp_error.cpp:5:28: warning: suggest braces around initialization of subobject [-Wmissing-braces]
std::array<int, 3> a = {1,2,3};
^~~~~
{ }
This should be a bug: https://llvm.org/bugs/show_bug.cgi?id=21629.
See also Is it wise to ignore gcc/clang's "-Wmissing-braces" warning?.
Use std::array<int, 3> a = {{1,2,3}};
instead.
See Why wasn't a double curly braces syntax preferred for constructors taking a std::initializer_list
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With