Opened 6 years ago

Last modified 6 years ago

#12431 new Bugs

BOOST_PP_TUPLE_PUSH_FRONT fails to expand with BOOST_PP_EXPAND

Reported by: mjtruog@… Owned by: No-Maintainer
Milestone: To Be Determined Component: preprocessor
Version: Boost 1.56.0 Severity: Problem
Keywords: Cc:

Description

This problem probably affects other preprocessor macros added in the 1.56.0 release, but this is one I bumped into. It is unfortunate that more bugs are appearing in the preprocessor code, since the original source code has been very useful and stable in the past, when it was first added. To compile the attached test2.cpp, use:

g++ -Wall -Wextra -Werror -g -O0 -save-temps -o test2.o -c -fpic test2.cpp

My testing has been using version 1.58, though this problem should have existed since 1.56.

Attachments (1)

test2.cpp (887 bytes ) - added by mjtruog@… 6 years ago.
test2.cpp

Download all attachments as: .zip

Change History (4)

by mjtruog@…, 6 years ago

Attachment: test2.cpp added

test2.cpp

comment:1 by mjtruog@…, 6 years ago

The diff below solves the problem, by bringing the code for the arity 0 case back to the state it was in at version 1.48 (when compared to 1.58):

--- /usr/include/boost/preprocessor/tuple/to_seq.hpp    2016-09-20 13:34:52.926120462 -0700
+++ /usr/include/boost/preprocessor/tuple/to_seq.hpp        2016-09-20 13:35:02.516377864 -0700
@@ -49,7 +49,7 @@
 # endif
 #
 /* An empty array can be passed */
-# define BOOST_PP_TUPLE_TO_SEQ_0() ()
+# define BOOST_PP_TUPLE_TO_SEQ_0()
 #
 # define BOOST_PP_TUPLE_TO_SEQ_1(e0) (e0)
 # define BOOST_PP_TUPLE_TO_SEQ_2(e0, e1) (e0)(e1)

comment:2 by mjtruog@…, 6 years ago

To avoid this bug in BOOST_PP_TUPLE_TO_SEQ I used the work-around below:

#include <boost/preprocessor/list/for_each.hpp>
#include <boost/preprocessor/tuple/to_list.hpp>

#define TUPLE_TO_SEQ_E(r, data, elem) (elem)
#define TUPLE_TO_SEQ(I, T) \
    BOOST_PP_LIST_FOR_EACH(TUPLE_TO_SEQ_E, _, BOOST_PP_TUPLE_TO_LIST(I, T))

comment:3 by mjtruog@…, 6 years ago

I mistakenly posted these comments to the wrong bug, they were meant to be at https://svn.boost.org/trac/boost/ticket/12426. I will put their contents there.

Note: See TracTickets for help on using tickets.