[array] GCC 4.2 warnings with array initialization

Hi all,
When building with boost 1.36 and GCC 4.2 under Xcode, the following
code produces a warning:
boost::array

AMDG Allen Cronce wrote:
When building with boost 1.36 and GCC 4.2 under Xcode, the following code produces a warning:
boost::array
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?
A compiler is not non-conforming because it issues a warning for legal code.
Sure enough, when I change the code to include a second set of braces, the warning is gone:
boost::array
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?
There is no way to disable the warning only for boost::array, AFAIK. In Christ, Steven Watanabe

Increase your warning tolerance. See: http://stackoverflow.com/questions/1067827/dangerous-ways-of-removing-compil... 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
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
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@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users

On Mon, Jul 13, 2009 at 07:18:42AM +0200, plarroy wrote:
Allen Cronce wrote:
When building with boost 1.36 and GCC 4.2 under Xcode, the following code produces a warning:
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?
Use the option -isystem to consider Boost as system header files so that warnings in it are supressed. Jens
participants (4)
-
Allen Cronce
-
Jens Seidel
-
plarroy
-
Steven Watanabe