
Ian McCulloch wrote:
Hi,
In boost 1.33.1, using MPL with gcc -pedantic gives an annoying error, boost/mpl/print.hpp:62: error: comma at end of enumerator list The trivial fix is to remove the comma at the end of line 60 of that file, which I did for my downloaded copy of boost ages ago, then promptly forgot about it. But I just checked the CVS and it seems that this bug is still present in both HEAD and RC_1_34_0. It would be great if this could be fixed before 1.34.
To followup: this bug seems to only affect gcc 3.3.3, gcc 3.3.5 and later (I also tested 3.4.5) are NOT affected. Test case: #include <boost/mpl/print.hpp> int main() {} With GCC 3.3.3: ianmcc@master:~> g++ --version g++ (GCC) 3.3.3 (SuSE Linux) Copyright (C) 2003 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ianmcc@master:~> g++ -pedantic -I. test.cpp In file included from test.cpp:1: boost/mpl/print.hpp:62: error: comma at end of enumerator list With GCC 3.3.5: ianmcc@lxtc226 ~ $ g++ --version g++ (GCC) 3.3.4 (pre 3.3.5 20040809) Copyright (C) 2003 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ianmcc@lxtc226 ~ $ g++ -pedantic test.cpp ianmcc@lxtc226 ~ $ ./a.out Nevertheless, C++98 appears to not allow a comma at the end of an enumerator-list. From A.6, enum-specifier: enum itentifier_opt { enumerator-list_opt } enumerator-list: enumerator-definition enumerator-list , enumerator-definition So it seems that the additional comma in the enumerator in boost/mpl/print.hpp is technically not allowed, but for whatever reason gcc removed the diagnostic sometime around version 3.3.4 or 3.3.5. I only have a 1997 working draft of the C standard but that could reveal why: it seems that C allows the extra comma. From 6.5.2.2: enum-specified: enum identifier_opt { enumerator-list } enum identifier_opt { enumerator-list , } enum identifier Although it seems to only affect one compiler, and then only in -pedantic mode, it is a trivial patch and the current code does seem to be non-standard c++. Any reason not to apply? --- print.hpp.old 2006-10-20 14:16:26.000000000 +0200 +++ print.hpp 2006-10-20 14:16:41.000000000 +0200 @@ -57,7 +57,7 @@ # if defined(__EDG_VERSION__) aux::dependent_unsigned<T>::value > -1 # else - sizeof(T) > -1, + sizeof(T) > -1 # endif }; #endif Regards, Ian McCulloch