Boost logo

Boost Users :

Subject: Re: [Boost-users] [array] GCC 4.2 warnings with array initialization
From: plarroy (plarroy_at_[hidden])
Date: 2009-07-13 01:18:42


Increase your warning tolerance.

See:

http://stackoverflow.com/questions/1067827/dangerous-ways-of-removing-compiler-warnings/1068439#1068439

Regards.

Allen Cronce wrote:
> 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
>
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>
>


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net