[Boost-bugs] [Boost C++ Libraries] #6989: BOOST_PP_SEQ_ELEM/BOOST_PP_IF behave differently on different compilers

Subject: [Boost-bugs] [Boost C++ Libraries] #6989: BOOST_PP_SEQ_ELEM/BOOST_PP_IF behave differently on different compilers
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2012-06-14 17:19:10


#6989: BOOST_PP_SEQ_ELEM/BOOST_PP_IF behave differently on different compilers
--------------------------------+-------------------------------------------
 Reporter: vanyacpp@… | Owner: no-maintainer
     Type: Bugs | Status: new
Milestone: To Be Determined | Component: preprocessor
  Version: Boost 1.49.0 | Severity: Problem
 Keywords: |
--------------------------------+-------------------------------------------
 MSVC accepts the following code, but gcc reject it with error message that
 it is impossible to get second element of sequence with size = 1. The
 problem is that gcc and clang expand both HANDLE_SIZE_EQ_1 and
 HANDLE_SIZE_EQ_2 before expanding BOOST_PP_IF.

 As it turned out MSVC and GCC get different versions of BOOST_PP_SEQ_ELEM.
 When MSVC get version of BOOST_PP_SEQ_ELEM for GCC it also show warning.

 See connect.microsoft.com/VisualStudio/feedback/details/743894/possibly-
 incorrect-macro-expansion-order for details.

 // boost version 1.49
 #include <boost/preprocessor/comparison/not_equal.hpp>
 #include <boost/preprocessor/seq/cat.hpp>
 #include <boost/preprocessor/seq/elem.hpp>
 #include <boost/preprocessor/seq/size.hpp>

 #define HANDLE_SIZE_EQ_1(seq)

 #define HANDLE_SIZE_EQ_2(seq)
 \
     BOOST_PP_SEQ_ELEM(1, seq)

 #define TEST_IF(seq) \
     BOOST_PP_IF(BOOST_PP_NOT_EQUAL(2, BOOST_PP_SEQ_SIZE(seq)) \
     , HANDLE_SIZE_EQ_1(seq) \
     , HANDLE_SIZE_EQ_2(seq))

 TEST_IF((a))

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/6989>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:09 UTC