Opened 15 years ago

Closed 14 years ago

#1051 closed Bugs (fixed)

MPL header ordering triggers bug

Reported by: aribrei@… Owned by: Aleksey Gurtovoy
Milestone: To Be Determined Component: mpl
Version: Severity: Problem
Keywords: Cc:

Description

If I include <boost/mpl/map.hpp> after a series of MPL headers, my build breaks.

When attached source is compiled with X defined, I get the following error message:

/usr/include/boost/mpl/map/aux_/contains_impl.hpp:31: error: ‘apply’ in class ‘boost::mpl::at_impl<boost::mpl::aux::map_tag>’ does not name a type
/usr/include/boost/mpl/map/aux_/contains_impl.hpp:31: error: expected template-argument before ‘<’ token
/usr/include/boost/mpl/map/aux_/contains_impl.hpp:31: error: expected `>' before ‘<’ token
/usr/include/boost/mpl/map/aux_/contains_impl.hpp:34: error: wrong number of template arguments (1, should be 2)
/usr/include/boost/type_traits/is_same.hpp:37: error: provided for ‘template<class T, class U> struct boost::is_same’
/usr/include/boost/mpl/map/aux_/contains_impl.hpp:34: error: expected `{' before ‘type’
/usr/include/boost/mpl/map/aux_/contains_impl.hpp:35: error: invalid type in declaration before ‘,’ token
/usr/include/boost/mpl/map/aux_/contains_impl.hpp:35: error: expected `;' before ‘,’ token
/usr/include/boost/mpl/map/aux_/contains_impl.hpp:38: error: data member ‘type’ cannot be a member template
/usr/include/boost/mpl/map/aux_/has_key_impl.hpp:33: error: ‘apply’ in class ‘boost::mpl::at_impl<boost::mpl::aux::map_tag>’ does not name a type
/usr/include/boost/mpl/map/aux_/has_key_impl.hpp:33: error: expected template-argument before ‘<’ token
/usr/include/boost/mpl/map/aux_/has_key_impl.hpp:33: error: expected `>' before ‘<’ token
/usr/include/boost/mpl/map/aux_/has_key_impl.hpp:33: error: template argument 1 is invalid
/usr/include/boost/mpl/map/aux_/has_key_impl.hpp:33: error: expected `{' before ‘type’
/usr/include/boost/mpl/map/aux_/has_key_impl.hpp:34: error: expected initializer before ‘>’ token
/usr/include/boost/mpl/map/aux_/iterator.hpp:41: error: template argument 1 is invalid
/usr/include/boost/mpl/map/aux_/iterator.hpp:41: error: template argument 1 is invalid
/usr/include/boost/mpl/map/aux_/iterator.hpp:44: error: expected `{' before ‘>’ token
/usr/include/boost/mpl/map/aux_/iterator.hpp:44: error: expected unqualified-id before ‘>’ token
/usr/include/boost/mpl/map/aux_/iterator.hpp:62: error: expected nested-name-specifier before ‘item_by_order’
/usr/include/boost/mpl/map/aux_/iterator.hpp:62: error: expected ‘;’ before ‘<’ token

Attachments (1)

test1.cpp (479 bytes ) - added by aribrei@… 15 years ago.
Compile with -DX to trigger failure

Download all attachments as: .zip

Change History (4)

by aribrei@…, 15 years ago

Attachment: test1.cpp added

Compile with -DX to trigger failure

comment:1 by Dave Abrahams, 15 years ago

Owner: set to Aleksey Gurtovoy

comment:2 by Steven Watanabe, 14 years ago

I guess the solution is "don't do that." #define X or the equivalent -DX is a bad idea, as is defining any other such short name as a macro.

comment:3 by aribrei@…, 14 years ago

Resolution: fixed
Status: newclosed

I cannot reproduce the problem on 1.37, so it seems to be fixed, actually. But, Steven Watanabe is completely wrong, the #define X is not even related to the problem. When I reported the problem, the same error would appear without any such #define. Claiming "-DX is a bad idea" without even looking at the relevant code is a most stupid idea, as it could be easily seen from the code that "#ifdef X" was added for testing purposes.

Also, if MPL would actually use X as a define internally without first checking for its existence, that would be a bug as well. Fortunately that is not the case, and never has been.

Note: See TracTickets for help on using tickets.