According to GCC 4.6.3 (Ubuntu / Linaro 4.6.3-1ubuntu5) I miss the curly brace in initializing the array in the following code:
#include <iostream> #include <boost/array.hpp> #include <array> int main(){ int plain[] = {1,2,3,4,5}; std::array <int, 5> std_arr = {1,2,3,4,5}; // warning, see below boost::array<int, 5> boost_arr = {1,2,3,4,5}; // warning, see below std::cout << plain[0] << std_arr[1] << boost_arr[2] << std::endl; }
> g ++ test.cc -Wall -Wextra -pedantic --std = c ++ 0x
test.cc: in function "int main ()":
test.cc:7:47: warning: curly braces missing around initialization for "std :: array :: value_type [5] {aka int [5]}" [-Wmissing-braces]
test.cc:8:47: warning: curly braces missing around initialization for "int [5]" [-Wmissing-braces] Apparently ( GCC was missing bindings around the initializer ), this is a bug in GCC, even in a slightly different context. Responses differ from the "error message file" to "just disable the warning."
However, in the context of std::array or boost::array , is this warning unnecessary, or am I missing something important?
(I will probably add extra curly braces instead of turning off the warning, but I'm curious what the consequences are)
source share