$include_dir="/home/hyper-archives/boost-users/include"; include("$include_dir/msg-header.inc") ?>
Subject: [Boost-users] [array] GCC 4.2 warnings with array initialization
From: Allen Cronce (allenslists_at_[hidden])
Date: 2009-06-11 10:15:51
Hi all,
When building with boost 1.36 and GCC 4.2 under Xcode, the following  
code produces a warning:
        boost::array<int, 2> warningArray =
        {
                1, 2
        };
        warning: missing braces around initializer for 'int [2]'
We see no warnings with GCG 4.0. We have a zero warning tolerance. All  
warnings are counted as errors.
The boost::array documentation indicates that the single brace  
approach should work for conforming compilers, according to 8.5.1 (11)  
of the Standard. So does that mean that GCC 4.2 is non-conforming?
Sure enough, when I change the code to include a second set of braces,  
the warning is gone:
        
        boost::array<int, 2> noWarningArray =
        {
                {
                        1, 2
                }
        };
But this is a problem as we move to GCC 4.2 because a) we use  
initialized arrays all over the place, so this means a lot of little  
changes, and b) requiring an extra set of braces is counter intuitive  
and irritating at best.
I don't like the idea of making the above code changes, and I don't  
want to globally disable the warning because it might be useful for  
other code. Does anyone have a better solution?
Thanks in advance for any suggestions.
Best,
-- Allen Cronce