Any-Range containing transformed range fails when compiled with optimizations
Hi, I have a program which produces different results based on the compiler options. The program uses a boost::any_range containing a transformed range where the transformation function just returns a new object of a simple struct: #include <vector> #include <boost/range.hpp> #include <boost/range/any_range.hpp> #include <boost/range/adaptor/transformed.hpp> #include <iostream> template<typename T1, typename T2> void ASSERT_EQ(T1 x,T2 y) {assert(x == y);}; struct SourceEvent { std::uint32_t event; void* ptr; }; int main() { using boost::adaptors::transformed; using R = boost::any_range<SourceEvent, boost::forward_traversal_tag, SourceEvent, std::ptrdiff_t>; std::vector<std::int32_t> v(100); R r = v | transformed( [](auto const&) {return SourceEvent{0u, nullptr};} ); auto t = v | transformed( [](auto const&) {return SourceEvent{0u, nullptr};} ); ASSERT_EQ( 100u, boost::size(r) ); ASSERT_EQ( 100u, boost::size(t) ); for (auto const& i: t) { ASSERT_EQ(0u, i.event ); ASSERT_EQ(nullptr, i.ptr); } for (auto const& i: r) { ASSERT_EQ(0u, i.event ); ASSERT_EQ(nullptr, i.ptr); } std::cout << "OK" << std::endl; return 0; } When compiled without optimization, it just prints ok. The same source compiled with optimizations asserts, and prints some interesting warnings: In file included from /usr/local/boost-1.60.0/include/boost/range/detail/any_iterator.hpp:22:0, from /usr/local/boost-1.60.0/include/boost/range/any_range.hpp:17, from prog.cc:3: /usr/local/boost-1.60.0/include/boost/range/detail/any_iterator_wrapper.hpp: In member function 'boost::range_detail::any_forward_iterator_wrapper<WrappedIterator, Reference, Buffer>::reference boost::range_detail::any_forward_iterator_wrapper<WrappedIterator, Reference, Buffer>::dereference() const [with WrappedIterator = boost::iterators::transform_iterator<boost::range_detail::default_constructible_unary_fn_wrapper<main()::<lambda(const auto:1&)>, SourceEvent>, __gnu_cxx::__normal_iterator<int*, std::vector<int> >, boost::iterators::use_default, boost::iterators::use_default>; Reference = SourceEvent; Buffer = boost::any_iterator_buffer<64ul>; boost::range_detail::any_forward_iterator_wrapper<WrappedIterator, Reference, Buffer>::reference = SourceEvent&]': /usr/local/boost-1.60.0/include/boost/range/detail/any_iterator_wrapper.hpp:302:57: warning: function may return address of local variable [-Wreturn-local-addr] return dereference_cast<reference>(*m_it); ^ /usr/local/boost-1.60.0/include/boost/range/detail/any_iterator_wrapper.hpp:302:52: note: declared here return dereference_cast<reference>(*m_it); ^ prog.exe: prog.cc:7: void ASSERT_EQ(T1, T2) [with T1 = unsigned int; T2 = unsigned int]: Assertion `x == y' failed. Aborted The example is compiled with gcc 5.2 and boost 1.60 (http://melpon.org/wandbox/permlink/QF1qyw5bWHKwyKJ8). Is there an error in my code? I would guess that transforming a range into a range of new objects of another type is quite common, so it should work. I am also curious why the warning is only emitted when compiling with optimizations. Best wishes, Jens -- Jens Auer | CGI | Software-Engineer CGI (Germany) GmbH & Co. KG Rheinstraße 95 | 64295 Darmstadt | Germany T: +49 6151 36860 154 jens.auer@cgi.com<mailto:jens.auer@cgi.com> Unsere Pflichtangaben gemäß § 35a GmbHG / §§ 161, 125a HGB finden Sie unter de.cgi.com/pflichtangaben<http://de.cgi.com/pflichtangaben>. CONFIDENTIALITY NOTICE: Proprietary/Confidential information belonging to CGI Group Inc. and its affiliates may be contained in this message. If you are not a recipient indicated or intended in this message (or responsible for delivery of this message to such person), or you think for any reason that this message may have been addressed to you in error, you may not use or copy or deliver this message to anyone else. In such case, you should destroy this message and are asked to notify the sender by reply e-mail.
I have just tested the same code clang 3.7. Here, everything compiles without warnings and works as expected. -- Jens Auer | CGI | Software-Engineer CGI (Germany) GmbH & Co. KG Rheinstraße 95 | 64295 Darmstadt | Germany T: +49 6151 36860 154 jens.auer@cgi.com Unsere Pflichtangaben gemäß § 35a GmbHG / §§ 161, 125a HGB finden Sie unter de.cgi.com/pflichtangaben. CONFIDENTIALITY NOTICE: Proprietary/Confidential information belonging to CGI Group Inc. and its affiliates may be contained in this message. If you are not a recipient indicated or intended in this message (or responsible for delivery of this message to such person), or you think for any reason that this message may have been addressed to you in error, you may not use or copy or deliver this message to anyone else. In such case, you should destroy this message and are asked to notify the sender by reply e-mail. ________________________________________ Von: Boost [boost-bounces@lists.boost.org]" im Auftrag von "Auer, Jens [jens.auer@cgi.com] Gesendet: Donnerstag, 14. Januar 2016 21:28 An: boost@lists.boost.org Betreff: [boost] Any-Range containing transformed range fails when compiled with optimizations Hi, I have a program which produces different results based on the compiler options. The program uses a boost::any_range containing a transformed range where the transformation function just returns a new object of a simple struct: #include <vector> #include <boost/range.hpp> #include <boost/range/any_range.hpp> #include <boost/range/adaptor/transformed.hpp> #include <iostream> template<typename T1, typename T2> void ASSERT_EQ(T1 x,T2 y) {assert(x == y);}; struct SourceEvent { std::uint32_t event; void* ptr; }; int main() { using boost::adaptors::transformed; using R = boost::any_range<SourceEvent, boost::forward_traversal_tag, SourceEvent, std::ptrdiff_t>; std::vector<std::int32_t> v(100); R r = v | transformed( [](auto const&) {return SourceEvent{0u, nullptr};} ); auto t = v | transformed( [](auto const&) {return SourceEvent{0u, nullptr};} ); ASSERT_EQ( 100u, boost::size(r) ); ASSERT_EQ( 100u, boost::size(t) ); for (auto const& i: t) { ASSERT_EQ(0u, i.event ); ASSERT_EQ(nullptr, i.ptr); } for (auto const& i: r) { ASSERT_EQ(0u, i.event ); ASSERT_EQ(nullptr, i.ptr); } std::cout << "OK" << std::endl; return 0; } When compiled without optimization, it just prints ok. The same source compiled with optimizations asserts, and prints some interesting warnings: In file included from /usr/local/boost-1.60.0/include/boost/range/detail/any_iterator.hpp:22:0, from /usr/local/boost-1.60.0/include/boost/range/any_range.hpp:17, from prog.cc:3: /usr/local/boost-1.60.0/include/boost/range/detail/any_iterator_wrapper.hpp: In member function 'boost::range_detail::any_forward_iterator_wrapper<WrappedIterator, Reference, Buffer>::reference boost::range_detail::any_forward_iterator_wrapper<WrappedIterator, Reference, Buffer>::dereference() const [with WrappedIterator = boost::iterators::transform_iterator<boost::range_detail::default_constructible_unary_fn_wrapper<main()::<lambda(const auto:1&)>, SourceEvent>, __gnu_cxx::__normal_iterator<int*, std::vector<int> >, boost::iterators::use_default, boost::iterators::use_default>; Reference = SourceEvent; Buffer = boost::any_iterator_buffer<64ul>; boost::range_detail::any_forward_iterator_wrapper<WrappedIterator, Reference, Buffer>::reference = SourceEvent&]': /usr/local/boost-1.60.0/include/boost/range/detail/any_iterator_wrapper.hpp:302:57: warning: function may return address of local variable [-Wreturn-local-addr] return dereference_cast<reference>(*m_it); ^ /usr/local/boost-1.60.0/include/boost/range/detail/any_iterator_wrapper.hpp:302:52: note: declared here return dereference_cast<reference>(*m_it); ^ prog.exe: prog.cc:7: void ASSERT_EQ(T1, T2) [with T1 = unsigned int; T2 = unsigned int]: Assertion `x == y' failed. Aborted The example is compiled with gcc 5.2 and boost 1.60 (http://melpon.org/wandbox/permlink/QF1qyw5bWHKwyKJ8). Is there an error in my code? I would guess that transforming a range into a range of new objects of another type is quite common, so it should work. I am also curious why the warning is only emitted when compiling with optimizations. Best wishes, Jens -- Jens Auer | CGI | Software-Engineer CGI (Germany) GmbH & Co. KG Rheinstraße 95 | 64295 Darmstadt | Germany T: +49 6151 36860 154 jens.auer@cgi.com<mailto:jens.auer@cgi.com> Unsere Pflichtangaben gemäß § 35a GmbHG / §§ 161, 125a HGB finden Sie unter de.cgi.com/pflichtangaben<http://de.cgi.com/pflichtangaben>. CONFIDENTIALITY NOTICE: Proprietary/Confidential information belonging to CGI Group Inc. and its affiliates may be contained in this message. If you are not a recipient indicated or intended in this message (or responsible for delivery of this message to such person), or you think for any reason that this message may have been addressed to you in error, you may not use or copy or deliver this message to anyone else. In such case, you should destroy this message and are asked to notify the sender by reply e-mail. _______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
I've made some more investigations. I modified the program slightly to be able to compile it with older gcc and boost versions to see when it broke. Our project uses gcc 4.9.2 with boost 1.55, but when one of my colleagues compiled it on his local machine with gcc 5.2 and boost 1.59 we started to see the issues. The new version of the code is: #include <vector> #include <boost/range.hpp> #include <boost/range/any_range.hpp> #include <boost/range/adaptor/transformed.hpp> #include <iostream> template<typename T1, typename T2> void ASSERT_EQ(T1 x,T2 y) {assert(x == y);}; struct SourceEvent { std::uint32_t event; void* ptr; }; SourceEvent f(std::int32_t x) { return SourceEvent{0u, nullptr}; } int main() { using boost::adaptors::transformed; using R = boost::any_range<SourceEvent, boost::forward_traversal_tag, SourceEvent, std::ptrdiff_t>; std::vector<std::int32_t> v(100); R r = v | transformed( f ); auto t = v | transformed( f ); //ASSERT_EQ( 100u, boost::size(r) ); //ASSERT_EQ( 100u, boost::size(t) ); for (auto const& i: t) { ASSERT_EQ(0u, i.event ); ASSERT_EQ(nullptr, i.ptr); } for (auto const& i: r) { ASSERT_EQ(0u, i.event ); ASSERT_EQ(nullptr, i.ptr); } std::cout << "OK" << std::endl; return 0; } It fails with gcc 4.9.2 and boost 1.56: http://melpon.org/wandbox/permlink/IWuz9TfbdtJdcn45 Start prog.cc:15:28: warning: unused parameter 'x' [-Wunused-parameter] SourceEvent f(std::int32_t x) ^ prog.exe: prog.cc:7: void ASSERT_EQ(T1, T2) [with T1 = unsigned int; T2 = unsigned int]: Assertion `x == y' failed. Aborted Finish but works with boost 1.55 (altohugh it emits a ton of warnings): http://melpon.org/wandbox/permlink/vZNaxeCU7ncnH1NZ Start ... warnings removed ... OK 0 Finish So it looks like some change in boost-1.56 is causing this. Best wishes, Jens PS: The links are links to the wandbox online compiler with the examples. PPS: Here are the warnings generated with gcc 4.9.2 and boost 1.55: In file included from /usr/local/boost-1.55.0/include/boost/mpl/aux_/integral_wrapper.hpp:22:0, from /usr/local/boost-1.55.0/include/boost/mpl/int.hpp:20, from /usr/local/boost-1.55.0/include/boost/type_traits/detail/template_arity_spec.hpp:10, from /usr/local/boost-1.55.0/include/boost/type_traits/detail/bool_trait_def.hpp:14, from /usr/local/boost-1.55.0/include/boost/type_traits/is_volatile.hpp:40, from /usr/local/boost-1.55.0/include/boost/type_traits/remove_const.hpp:14, from /usr/local/boost-1.55.0/include/boost/range/const_iterator.hpp:25, from /usr/local/boost-1.55.0/include/boost/range/iterator.hpp:20, from /usr/local/boost-1.55.0/include/boost/range/begin.hpp:24, from /usr/local/boost-1.55.0/include/boost/range/functions.hpp:18, from /usr/local/boost-1.55.0/include/boost/range.hpp:26, from prog.cc:2: /usr/local/boost-1.55.0/include/boost/concept_check.hpp: In function 'void boost::function_requires(Model*)': /usr/local/boost-1.55.0/include/boost/concept/detail/general.hpp:71:20: warning: typedef 'boost_concept_check45' locally defined but not used [-Wunused-local-typedefs] BOOST_PP_CAT(boost_concept_check,__LINE__) ^ /usr/local/boost-1.55.0/include/boost/preprocessor/cat.hpp:29:34: note: in definition of macro 'BOOST_PP_CAT_I' # define BOOST_PP_CAT_I(a, b) a ## b ^ /usr/local/boost-1.55.0/include/boost/concept/detail/general.hpp:71:7: note: in expansion of macro 'BOOST_PP_CAT' BOOST_PP_CAT(boost_concept_check,__LINE__) ^ /usr/local/boost-1.55.0/include/boost/concept/assert.hpp:44:5: note: in expansion of macro 'BOOST_CONCEPT_ASSERT_FN' BOOST_CONCEPT_ASSERT_FN(void(*)ModelInParens) ^ /usr/local/boost-1.55.0/include/boost/concept_check.hpp:45:7: note: in expansion of macro 'BOOST_CONCEPT_ASSERT' BOOST_CONCEPT_ASSERT((Model)); ^ /usr/local/boost-1.55.0/include/boost/concept_check.hpp: In destructor 'boost::AdaptableGenerator<Func, Return>::~AdaptableGenerator()': /usr/local/boost-1.55.0/include/boost/concept/detail/general.hpp:71:20: warning: typedef 'boost_concept_check453' locally defined but not used [-Wunused-local-typedefs] BOOST_PP_CAT(boost_concept_check,__LINE__) ^ /usr/local/boost-1.55.0/include/boost/preprocessor/cat.hpp:29:34: note: in definition of macro 'BOOST_PP_CAT_I' # define BOOST_PP_CAT_I(a, b) a ## b ^ /usr/local/boost-1.55.0/include/boost/concept/detail/general.hpp:71:7: note: in expansion of macro 'BOOST_PP_CAT' BOOST_PP_CAT(boost_concept_check,__LINE__) ^ /usr/local/boost-1.55.0/include/boost/concept/assert.hpp:44:5: note: in expansion of macro 'BOOST_CONCEPT_ASSERT_FN' BOOST_CONCEPT_ASSERT_FN(void(*)ModelInParens) ^ /usr/local/boost-1.55.0/include/boost/concept_check.hpp:453:11: note: in expansion of macro 'BOOST_CONCEPT_ASSERT' BOOST_CONCEPT_ASSERT((Convertible<result_type, Return>)); ^ /usr/local/boost-1.55.0/include/boost/concept_check.hpp: In destructor 'boost::AdaptableUnaryFunction<Func, Return, Arg>::~AdaptableUnaryFunction()': /usr/local/boost-1.55.0/include/boost/concept/detail/general.hpp:71:20: warning: typedef 'boost_concept_check465' locally defined but not used [-Wunused-local-typedefs] BOOST_PP_CAT(boost_concept_check,__LINE__) ^ /usr/local/boost-1.55.0/include/boost/preprocessor/cat.hpp:29:34: note: in definition of macro 'BOOST_PP_CAT_I' # define BOOST_PP_CAT_I(a, b) a ## b ^ /usr/local/boost-1.55.0/include/boost/concept/detail/general.hpp:71:7: note: in expansion of macro 'BOOST_PP_CAT' BOOST_PP_CAT(boost_concept_check,__LINE__) ^ /usr/local/boost-1.55.0/include/boost/concept/assert.hpp:44:5: note: in expansion of macro 'BOOST_CONCEPT_ASSERT_FN' BOOST_CONCEPT_ASSERT_FN(void(*)ModelInParens) ^ /usr/local/boost-1.55.0/include/boost/concept_check.hpp:465:11: note: in expansion of macro 'BOOST_CONCEPT_ASSERT' BOOST_CONCEPT_ASSERT((Convertible<result_type, Return>)); ^ /usr/local/boost-1.55.0/include/boost/concept/detail/general.hpp:71:20: warning: typedef 'boost_concept_check466' locally defined but not used [-Wunused-local-typedefs] BOOST_PP_CAT(boost_concept_check,__LINE__) ^ /usr/local/boost-1.55.0/include/boost/preprocessor/cat.hpp:29:34: note: in definition of macro 'BOOST_PP_CAT_I' # define BOOST_PP_CAT_I(a, b) a ## b ^ /usr/local/boost-1.55.0/include/boost/concept/detail/general.hpp:71:7: note: in expansion of macro 'BOOST_PP_CAT' BOOST_PP_CAT(boost_concept_check,__LINE__) ^ /usr/local/boost-1.55.0/include/boost/concept/assert.hpp:44:5: note: in expansion of macro 'BOOST_CONCEPT_ASSERT_FN' BOOST_CONCEPT_ASSERT_FN(void(*)ModelInParens) ^ /usr/local/boost-1.55.0/include/boost/concept_check.hpp:466:11: note: in expansion of macro 'BOOST_CONCEPT_ASSERT' BOOST_CONCEPT_ASSERT((Convertible<Arg, argument_type>)); ^ /usr/local/boost-1.55.0/include/boost/concept_check.hpp: In destructor 'boost::AdaptableBinaryFunction<Func, Return, First, Second>::~AdaptableBinaryFunction()': /usr/local/boost-1.55.0/include/boost/concept/detail/general.hpp:71:20: warning: typedef 'boost_concept_check484' locally defined but not used [-Wunused-local-typedefs] BOOST_PP_CAT(boost_concept_check,__LINE__) ^ /usr/local/boost-1.55.0/include/boost/preprocessor/cat.hpp:29:34: note: in definition of macro 'BOOST_PP_CAT_I' # define BOOST_PP_CAT_I(a, b) a ## b ^ /usr/local/boost-1.55.0/include/boost/concept/detail/general.hpp:71:7: note: in expansion of macro 'BOOST_PP_CAT' BOOST_PP_CAT(boost_concept_check,__LINE__) ^ /usr/local/boost-1.55.0/include/boost/concept/assert.hpp:44:5: note: in expansion of macro 'BOOST_CONCEPT_ASSERT_FN' BOOST_CONCEPT_ASSERT_FN(void(*)ModelInParens) ^ /usr/local/boost-1.55.0/include/boost/concept_check.hpp:484:11: note: in expansion of macro 'BOOST_CONCEPT_ASSERT' BOOST_CONCEPT_ASSERT((Convertible<result_type, Return>)); ^ /usr/local/boost-1.55.0/include/boost/concept/detail/general.hpp:71:20: warning: typedef 'boost_concept_check485' locally defined but not used [-Wunused-local-typedefs] BOOST_PP_CAT(boost_concept_check,__LINE__) ^ /usr/local/boost-1.55.0/include/boost/preprocessor/cat.hpp:29:34: note: in definition of macro 'BOOST_PP_CAT_I' # define BOOST_PP_CAT_I(a, b) a ## b ^ /usr/local/boost-1.55.0/include/boost/concept/detail/general.hpp:71:7: note: in expansion of macro 'BOOST_PP_CAT' BOOST_PP_CAT(boost_concept_check,__LINE__) ^ /usr/local/boost-1.55.0/include/boost/concept/assert.hpp:44:5: note: in expansion of macro 'BOOST_CONCEPT_ASSERT_FN' BOOST_CONCEPT_ASSERT_FN(void(*)ModelInParens) ^ /usr/local/boost-1.55.0/include/boost/concept_check.hpp:485:11: note: in expansion of macro 'BOOST_CONCEPT_ASSERT' BOOST_CONCEPT_ASSERT((Convertible<First, first_argument_type>)); ^ /usr/local/boost-1.55.0/include/boost/concept/detail/general.hpp:71:20: warning: typedef 'boost_concept_check486' locally defined but not used [-Wunused-local-typedefs] BOOST_PP_CAT(boost_concept_check,__LINE__) ^ /usr/local/boost-1.55.0/include/boost/preprocessor/cat.hpp:29:34: note: in definition of macro 'BOOST_PP_CAT_I' # define BOOST_PP_CAT_I(a, b) a ## b ^ /usr/local/boost-1.55.0/include/boost/concept/detail/general.hpp:71:7: note: in expansion of macro 'BOOST_PP_CAT' BOOST_PP_CAT(boost_concept_check,__LINE__) ^ /usr/local/boost-1.55.0/include/boost/concept/assert.hpp:44:5: note: in expansion of macro 'BOOST_CONCEPT_ASSERT_FN' BOOST_CONCEPT_ASSERT_FN(void(*)ModelInParens) ^ /usr/local/boost-1.55.0/include/boost/concept_check.hpp:486:11: note: in expansion of macro 'BOOST_CONCEPT_ASSERT' BOOST_CONCEPT_ASSERT((Convertible<Second, second_argument_type>)); ^ /usr/local/boost-1.55.0/include/boost/concept_check.hpp: In destructor 'boost::InputIterator<TT>::~InputIterator()': /usr/local/boost-1.55.0/include/boost/concept/detail/general.hpp:71:20: warning: typedef 'boost_concept_check517' locally defined but not used [-Wunused-local-typedefs] BOOST_PP_CAT(boost_concept_check,__LINE__) ^ /usr/local/boost-1.55.0/include/boost/preprocessor/cat.hpp:29:34: note: in definition of macro 'BOOST_PP_CAT_I' # define BOOST_PP_CAT_I(a, b) a ## b ^ /usr/local/boost-1.55.0/include/boost/concept/detail/general.hpp:71:7: note: in expansion of macro 'BOOST_PP_CAT' BOOST_PP_CAT(boost_concept_check,__LINE__) ^ /usr/local/boost-1.55.0/include/boost/concept/assert.hpp:44:5: note: in expansion of macro 'BOOST_CONCEPT_ASSERT_FN' BOOST_CONCEPT_ASSERT_FN(void(*)ModelInParens) ^ /usr/local/boost-1.55.0/include/boost/concept_check.hpp:517:9: note: in expansion of macro 'BOOST_CONCEPT_ASSERT' BOOST_CONCEPT_ASSERT((SignedInteger<difference_type>)); ^ /usr/local/boost-1.55.0/include/boost/concept/detail/general.hpp:71:20: warning: typedef 'boost_concept_check518' locally defined but not used [-Wunused-local-typedefs] BOOST_PP_CAT(boost_concept_check,__LINE__) ^ /usr/local/boost-1.55.0/include/boost/preprocessor/cat.hpp:29:34: note: in definition of macro 'BOOST_PP_CAT_I' # define BOOST_PP_CAT_I(a, b) a ## b ^ /usr/local/boost-1.55.0/include/boost/concept/detail/general.hpp:71:7: note: in expansion of macro 'BOOST_PP_CAT' BOOST_PP_CAT(boost_concept_check,__LINE__) ^ /usr/local/boost-1.55.0/include/boost/concept/assert.hpp:44:5: note: in expansion of macro 'BOOST_CONCEPT_ASSERT_FN' BOOST_CONCEPT_ASSERT_FN(void(*)ModelInParens) ^ /usr/local/boost-1.55.0/include/boost/concept_check.hpp:518:9: note: in expansion of macro 'BOOST_CONCEPT_ASSERT' BOOST_CONCEPT_ASSERT((Convertible<iterator_category, std::input_iterator_tag>)); ^ /usr/local/boost-1.55.0/include/boost/concept_check.hpp: In destructor 'boost::ForwardIterator<TT>::~ForwardIterator()': /usr/local/boost-1.55.0/include/boost/concept/detail/general.hpp:71:20: warning: typedef 'boost_concept_check551' locally defined but not used [-Wunused-local-typedefs] BOOST_PP_CAT(boost_concept_check,__LINE__) ^ /usr/local/boost-1.55.0/include/boost/preprocessor/cat.hpp:29:34: note: in definition of macro 'BOOST_PP_CAT_I' # define BOOST_PP_CAT_I(a, b) a ## b ^ /usr/local/boost-1.55.0/include/boost/concept/detail/general.hpp:71:7: note: in expansion of macro 'BOOST_PP_CAT' BOOST_PP_CAT(boost_concept_check,__LINE__) ^ /usr/local/boost-1.55.0/include/boost/concept/assert.hpp:44:5: note: in expansion of macro 'BOOST_CONCEPT_ASSERT_FN' BOOST_CONCEPT_ASSERT_FN(void(*)ModelInParens) ^ /usr/local/boost-1.55.0/include/boost/concept_check.hpp:548:11: note: in expansion of macro 'BOOST_CONCEPT_ASSERT' BOOST_CONCEPT_ASSERT((Convertible< ^ /usr/local/boost-1.55.0/include/boost/concept_check.hpp: In destructor 'boost::BidirectionalIterator<TT>::~BidirectionalIterator()': /usr/local/boost-1.55.0/include/boost/concept/detail/general.hpp:71:20: warning: typedef 'boost_concept_check579' locally defined but not used [-Wunused-local-typedefs] BOOST_PP_CAT(boost_concept_check,__LINE__) ^ /usr/local/boost-1.55.0/include/boost/preprocessor/cat.hpp:29:34: note: in definition of macro 'BOOST_PP_CAT_I' # define BOOST_PP_CAT_I(a, b) a ## b ^ /usr/local/boost-1.55.0/include/boost/concept/detail/general.hpp:71:7: note: in expansion of macro 'BOOST_PP_CAT' BOOST_PP_CAT(boost_concept_check,__LINE__) ^ /usr/local/boost-1.55.0/include/boost/concept/assert.hpp:44:5: note: in expansion of macro 'BOOST_CONCEPT_ASSERT_FN' BOOST_CONCEPT_ASSERT_FN(void(*)ModelInParens) ^ /usr/local/boost-1.55.0/include/boost/concept_check.hpp:576:11: note: in expansion of macro 'BOOST_CONCEPT_ASSERT' BOOST_CONCEPT_ASSERT((Convertible< ^ /usr/local/boost-1.55.0/include/boost/concept_check.hpp: In destructor 'boost::RandomAccessIterator<TT>::~RandomAccessIterator()': /usr/local/boost-1.55.0/include/boost/concept/detail/general.hpp:71:20: warning: typedef 'boost_concept_check609' locally defined but not used [-Wunused-local-typedefs] BOOST_PP_CAT(boost_concept_check,__LINE__) ^ /usr/local/boost-1.55.0/include/boost/preprocessor/cat.hpp:29:34: note: in definition of macro 'BOOST_PP_CAT_I' # define BOOST_PP_CAT_I(a, b) a ## b ^ /usr/local/boost-1.55.0/include/boost/concept/detail/general.hpp:71:7: note: in expansion of macro 'BOOST_PP_CAT' BOOST_PP_CAT(boost_concept_check,__LINE__) ^ /usr/local/boost-1.55.0/include/boost/concept/assert.hpp:44:5: note: in expansion of macro 'BOOST_CONCEPT_ASSERT_FN' BOOST_CONCEPT_ASSERT_FN(void(*)ModelInParens) ^ /usr/local/boost-1.55.0/include/boost/concept_check.hpp:606:11: note: in expansion of macro 'BOOST_CONCEPT_ASSERT' BOOST_CONCEPT_ASSERT((Convertible< ^ /usr/local/boost-1.55.0/include/boost/concept_check.hpp: In destructor 'boost::Container<C>::~Container()': /usr/local/boost-1.55.0/include/boost/concept/detail/general.hpp:71:20: warning: typedef 'boost_concept_check653' locally defined but not used [-Wunused-local-typedefs] BOOST_PP_CAT(boost_concept_check,__LINE__) ^ /usr/local/boost-1.55.0/include/boost/preprocessor/cat.hpp:29:34: note: in definition of macro 'BOOST_PP_CAT_I' # define BOOST_PP_CAT_I(a, b) a ## b ^ /usr/local/boost-1.55.0/include/boost/concept/detail/general.hpp:71:7: note: in expansion of macro 'BOOST_PP_CAT' BOOST_PP_CAT(boost_concept_check,__LINE__) ^ /usr/local/boost-1.55.0/include/boost/concept/assert.hpp:44:5: note: in expansion of macro 'BOOST_CONCEPT_ASSERT_FN' BOOST_CONCEPT_ASSERT_FN(void(*)ModelInParens) ^ /usr/local/boost-1.55.0/include/boost/concept_check.hpp:653:11: note: in expansion of macro 'BOOST_CONCEPT_ASSERT' BOOST_CONCEPT_ASSERT((InputIterator<const_iterator>)); ^ /usr/local/boost-1.55.0/include/boost/concept_check.hpp: In destructor 'boost::Mutable_Container<C>::~Mutable_Container()': /usr/local/boost-1.55.0/include/boost/concept/detail/general.hpp:71:20: warning: typedef 'boost_concept_check681' locally defined but not used [-Wunused-local-typedefs] BOOST_PP_CAT(boost_concept_check,__LINE__) ^ /usr/local/boost-1.55.0/include/boost/preprocessor/cat.hpp:29:34: note: in definition of macro 'BOOST_PP_CAT_I' # define BOOST_PP_CAT_I(a, b) a ## b ^ /usr/local/boost-1.55.0/include/boost/concept/detail/general.hpp:71:7: note: in expansion of macro 'BOOST_PP_CAT' BOOST_PP_CAT(boost_concept_check,__LINE__) ^ /usr/local/boost-1.55.0/include/boost/concept/assert.hpp:44:5: note: in expansion of macro 'BOOST_CONCEPT_ASSERT_FN' BOOST_CONCEPT_ASSERT_FN(void(*)ModelInParens) ^ /usr/local/boost-1.55.0/include/boost/concept_check.hpp:680:11: note: in expansion of macro 'BOOST_CONCEPT_ASSERT' BOOST_CONCEPT_ASSERT(( ^ /usr/local/boost-1.55.0/include/boost/concept/detail/general.hpp:71:20: warning: typedef 'boost_concept_check683' locally defined but not used [-Wunused-local-typedefs] BOOST_PP_CAT(boost_concept_check,__LINE__) ^ /usr/local/boost-1.55.0/include/boost/preprocessor/cat.hpp:29:34: note: in definition of macro 'BOOST_PP_CAT_I' # define BOOST_PP_CAT_I(a, b) a ## b ^ /usr/local/boost-1.55.0/include/boost/concept/detail/general.hpp:71:7: note: in expansion of macro 'BOOST_PP_CAT' BOOST_PP_CAT(boost_concept_check,__LINE__) ^ /usr/local/boost-1.55.0/include/boost/concept/assert.hpp:44:5: note: in expansion of macro 'BOOST_CONCEPT_ASSERT_FN' BOOST_CONCEPT_ASSERT_FN(void(*)ModelInParens) ^ /usr/local/boost-1.55.0/include/boost/concept_check.hpp:683:11: note: in expansion of macro 'BOOST_CONCEPT_ASSERT' BOOST_CONCEPT_ASSERT((InputIterator<iterator>)); ^ /usr/local/boost-1.55.0/include/boost/concept_check.hpp: In destructor 'boost::ForwardContainer<C>::~ForwardContainer()': /usr/local/boost-1.55.0/include/boost/concept/detail/general.hpp:71:20: warning: typedef 'boost_concept_check703' locally defined but not used [-Wunused-local-typedefs] BOOST_PP_CAT(boost_concept_check,__LINE__) ^ /usr/local/boost-1.55.0/include/boost/preprocessor/cat.hpp:29:34: note: in definition of macro 'BOOST_PP_CAT_I' # define BOOST_PP_CAT_I(a, b) a ## b ^ /usr/local/boost-1.55.0/include/boost/concept/detail/general.hpp:71:7: note: in expansion of macro 'BOOST_PP_CAT' BOOST_PP_CAT(boost_concept_check,__LINE__) ^ /usr/local/boost-1.55.0/include/boost/concept/assert.hpp:44:5: note: in expansion of macro 'BOOST_CONCEPT_ASSERT_FN' BOOST_CONCEPT_ASSERT_FN(void(*)ModelInParens) ^ /usr/local/boost-1.55.0/include/boost/concept_check.hpp:700:11: note: in expansion of macro 'BOOST_CONCEPT_ASSERT' BOOST_CONCEPT_ASSERT(( ^ /usr/local/boost-1.55.0/include/boost/concept_check.hpp: In destructor 'boost::Mutable_ForwardContainer<C>::~Mutable_ForwardContainer()': /usr/local/boost-1.55.0/include/boost/concept/detail/general.hpp:71:20: warning: typedef 'boost_concept_check716' locally defined but not used [-Wunused-local-typedefs] BOOST_PP_CAT(boost_concept_check,__LINE__) ^ /usr/local/boost-1.55.0/include/boost/preprocessor/cat.hpp:29:34: note: in definition of macro 'BOOST_PP_CAT_I' # define BOOST_PP_CAT_I(a, b) a ## b ^ /usr/local/boost-1.55.0/include/boost/concept/detail/general.hpp:71:7: note: in expansion of macro 'BOOST_PP_CAT' BOOST_PP_CAT(boost_concept_check,__LINE__) ^ /usr/local/boost-1.55.0/include/boost/concept/assert.hpp:44:5: note: in expansion of macro 'BOOST_CONCEPT_ASSERT_FN' BOOST_CONCEPT_ASSERT_FN(void(*)ModelInParens) ^ /usr/local/boost-1.55.0/include/boost/concept_check.hpp:713:11: note: in expansion of macro 'BOOST_CONCEPT_ASSERT' BOOST_CONCEPT_ASSERT(( ^ /usr/local/boost-1.55.0/include/boost/concept_check.hpp: In destructor 'boost::ReversibleContainer<C>::~ReversibleContainer()': /usr/local/boost-1.55.0/include/boost/concept/detail/general.hpp:71:20: warning: typedef 'boost_concept_check731' locally defined but not used [-Wunused-local-typedefs] BOOST_PP_CAT(boost_concept_check,__LINE__) ^ /usr/local/boost-1.55.0/include/boost/preprocessor/cat.hpp:29:34: note: in definition of macro 'BOOST_PP_CAT_I' # define BOOST_PP_CAT_I(a, b) a ## b ^ /usr/local/boost-1.55.0/include/boost/concept/detail/general.hpp:71:7: note: in expansion of macro 'BOOST_PP_CAT' BOOST_PP_CAT(boost_concept_check,__LINE__) ^ /usr/local/boost-1.55.0/include/boost/concept/assert.hpp:44:5: note: in expansion of macro 'BOOST_CONCEPT_ASSERT_FN' BOOST_CONCEPT_ASSERT_FN(void(*)ModelInParens) ^ /usr/local/boost-1.55.0/include/boost/concept_check.hpp:729:11: note: in expansion of macro 'BOOST_CONCEPT_ASSERT' BOOST_CONCEPT_ASSERT(( ^ /usr/local/boost-1.55.0/include/boost/concept/detail/general.hpp:71:20: warning: typedef 'boost_concept_check733' locally defined but not used [-Wunused-local-typedefs] BOOST_PP_CAT(boost_concept_check,__LINE__) ^ /usr/local/boost-1.55.0/include/boost/preprocessor/cat.hpp:29:34: note: in definition of macro 'BOOST_PP_CAT_I' # define BOOST_PP_CAT_I(a, b) a ## b ^ /usr/local/boost-1.55.0/include/boost/concept/detail/general.hpp:71:7: note: in expansion of macro 'BOOST_PP_CAT' BOOST_PP_CAT(boost_concept_check,__LINE__) ^ /usr/local/boost-1.55.0/include/boost/concept/assert.hpp:44:5: note: in expansion of macro 'BOOST_CONCEPT_ASSERT_FN' BOOST_CONCEPT_ASSERT_FN(void(*)ModelInParens) ^ /usr/local/boost-1.55.0/include/boost/concept_check.hpp:733:11: note: in expansion of macro 'BOOST_CONCEPT_ASSERT' BOOST_CONCEPT_ASSERT((BidirectionalIterator<const_reverse_iterator>)); ^ /usr/local/boost-1.55.0/include/boost/concept_check.hpp: In destructor 'boost::Mutable_ReversibleContainer<C>::~Mutable_ReversibleContainer()': /usr/local/boost-1.55.0/include/boost/concept/detail/general.hpp:71:20: warning: typedef 'boost_concept_check755' locally defined but not used [-Wunused-local-typedefs] BOOST_PP_CAT(boost_concept_check,__LINE__) ^ /usr/local/boost-1.55.0/include/boost/preprocessor/cat.hpp:29:34: note: in definition of macro 'BOOST_PP_CAT_I' # define BOOST_PP_CAT_I(a, b) a ## b ^ /usr/local/boost-1.55.0/include/boost/concept/detail/general.hpp:71:7: note: in expansion of macro 'BOOST_PP_CAT' BOOST_PP_CAT(boost_concept_check,__LINE__) ^ /usr/local/boost-1.55.0/include/boost/concept/assert.hpp:44:5: note: in expansion of macro 'BOOST_CONCEPT_ASSERT_FN' BOOST_CONCEPT_ASSERT_FN(void(*)ModelInParens) ^ /usr/local/boost-1.55.0/include/boost/concept_check.hpp:755:11: note: in expansion of macro 'BOOST_CONCEPT_ASSERT' BOOST_CONCEPT_ASSERT((Mutable_BidirectionalIterator<iterator>)); ^ /usr/local/boost-1.55.0/include/boost/concept/detail/general.hpp:71:20: warning: typedef 'boost_concept_check756' locally defined but not used [-Wunused-local-typedefs] BOOST_PP_CAT(boost_concept_check,__LINE__) ^ /usr/local/boost-1.55.0/include/boost/preprocessor/cat.hpp:29:34: note: in definition of macro 'BOOST_PP_CAT_I' # define BOOST_PP_CAT_I(a, b) a ## b ^ /usr/local/boost-1.55.0/include/boost/concept/detail/general.hpp:71:7: note: in expansion of macro 'BOOST_PP_CAT' BOOST_PP_CAT(boost_concept_check,__LINE__) ^ /usr/local/boost-1.55.0/include/boost/concept/assert.hpp:44:5: note: in expansion of macro 'BOOST_CONCEPT_ASSERT_FN' BOOST_CONCEPT_ASSERT_FN(void(*)ModelInParens) ^ /usr/local/boost-1.55.0/include/boost/concept_check.hpp:756:11: note: in expansion of macro 'BOOST_CONCEPT_ASSERT' BOOST_CONCEPT_ASSERT((Mutable_BidirectionalIterator<reverse_iterator>)); ^ /usr/local/boost-1.55.0/include/boost/concept_check.hpp: In destructor 'boost::RandomAccessContainer<C>::~RandomAccessContainer()': /usr/local/boost-1.55.0/include/boost/concept/detail/general.hpp:71:20: warning: typedef 'boost_concept_check776' locally defined but not used [-Wunused-local-typedefs] BOOST_PP_CAT(boost_concept_check,__LINE__) ^ /usr/local/boost-1.55.0/include/boost/preprocessor/cat.hpp:29:34: note: in definition of macro 'BOOST_PP_CAT_I' # define BOOST_PP_CAT_I(a, b) a ## b ^ /usr/local/boost-1.55.0/include/boost/concept/detail/general.hpp:71:7: note: in expansion of macro 'BOOST_PP_CAT' BOOST_PP_CAT(boost_concept_check,__LINE__) ^ /usr/local/boost-1.55.0/include/boost/concept/assert.hpp:44:5: note: in expansion of macro 'BOOST_CONCEPT_ASSERT_FN' BOOST_CONCEPT_ASSERT_FN(void(*)ModelInParens) ^ /usr/local/boost-1.55.0/include/boost/concept_check.hpp:773:11: note: in expansion of macro 'BOOST_CONCEPT_ASSERT' BOOST_CONCEPT_ASSERT(( ^ /usr/local/boost-1.55.0/include/boost/concept_check.hpp: In destructor 'boost::Mutable_RandomAccessContainer<C>::~Mutable_RandomAccessContainer()': /usr/local/boost-1.55.0/include/boost/concept/detail/general.hpp:71:20: warning: typedef 'boost_concept_check800' locally defined but not used [-Wunused-local-typedefs] BOOST_PP_CAT(boost_concept_check,__LINE__) ^ /usr/local/boost-1.55.0/include/boost/preprocessor/cat.hpp:29:34: note: in definition of macro 'BOOST_PP_CAT_I' # define BOOST_PP_CAT_I(a, b) a ## b ^ /usr/local/boost-1.55.0/include/boost/concept/detail/general.hpp:71:7: note: in expansion of macro 'BOOST_PP_CAT' BOOST_PP_CAT(boost_concept_check,__LINE__) ^ /usr/local/boost-1.55.0/include/boost/concept/assert.hpp:44:5: note: in expansion of macro 'BOOST_CONCEPT_ASSERT_FN' BOOST_CONCEPT_ASSERT_FN(void(*)ModelInParens) ^ /usr/local/boost-1.55.0/include/boost/concept_check.hpp:800:11: note: in expansion of macro 'BOOST_CONCEPT_ASSERT' BOOST_CONCEPT_ASSERT((Mutable_RandomAccessIterator<typename self::iterator>)); ^ /usr/local/boost-1.55.0/include/boost/concept/detail/general.hpp:71:20: warning: typedef 'boost_concept_check801' locally defined but not used [-Wunused-local-typedefs] BOOST_PP_CAT(boost_concept_check,__LINE__) ^ /usr/local/boost-1.55.0/include/boost/preprocessor/cat.hpp:29:34: note: in definition of macro 'BOOST_PP_CAT_I' # define BOOST_PP_CAT_I(a, b) a ## b ^ /usr/local/boost-1.55.0/include/boost/concept/detail/general.hpp:71:7: note: in expansion of macro 'BOOST_PP_CAT' BOOST_PP_CAT(boost_concept_check,__LINE__) ^ /usr/local/boost-1.55.0/include/boost/concept/assert.hpp:44:5: note: in expansion of macro 'BOOST_CONCEPT_ASSERT_FN' BOOST_CONCEPT_ASSERT_FN(void(*)ModelInParens) ^ /usr/local/boost-1.55.0/include/boost/concept_check.hpp:801:11: note: in expansion of macro 'BOOST_CONCEPT_ASSERT' BOOST_CONCEPT_ASSERT((Mutable_RandomAccessIterator<typename self::reverse_iterator>)); ^ /usr/local/boost-1.55.0/include/boost/concept_check.hpp: In destructor 'boost::AssociativeContainer<C>::~AssociativeContainer()': /usr/local/boost-1.55.0/include/boost/concept/detail/general.hpp:71:20: warning: typedef 'boost_concept_check905' locally defined but not used [-Wunused-local-typedefs] BOOST_PP_CAT(boost_concept_check,__LINE__) ^ /usr/local/boost-1.55.0/include/boost/preprocessor/cat.hpp:29:34: note: in definition of macro 'BOOST_PP_CAT_I' # define BOOST_PP_CAT_I(a, b) a ## b ^ /usr/local/boost-1.55.0/include/boost/concept/detail/general.hpp:71:7: note: in expansion of macro 'BOOST_PP_CAT' BOOST_PP_CAT(boost_concept_check,__LINE__) ^ /usr/local/boost-1.55.0/include/boost/concept/assert.hpp:44:5: note: in expansion of macro 'BOOST_CONCEPT_ASSERT_FN' BOOST_CONCEPT_ASSERT_FN(void(*)ModelInParens) ^ /usr/local/boost-1.55.0/include/boost/concept_check.hpp:905:11: note: in expansion of macro 'BOOST_CONCEPT_ASSERT' BOOST_CONCEPT_ASSERT((BinaryPredicate<key_compare,key_type,key_type>)); ^ /usr/local/boost-1.55.0/include/boost/concept/detail/general.hpp:71:20: warning: typedef 'boost_concept_check908' locally defined but not used [-Wunused-local-typedefs] BOOST_PP_CAT(boost_concept_check,__LINE__) ^ /usr/local/boost-1.55.0/include/boost/preprocessor/cat.hpp:29:34: note: in definition of macro 'BOOST_PP_CAT_I' # define BOOST_PP_CAT_I(a, b) a ## b ^ /usr/local/boost-1.55.0/include/boost/concept/detail/general.hpp:71:7: note: in expansion of macro 'BOOST_PP_CAT' BOOST_PP_CAT(boost_concept_check,__LINE__) ^ /usr/local/boost-1.55.0/include/boost/concept/assert.hpp:44:5: note: in expansion of macro 'BOOST_CONCEPT_ASSERT_FN' BOOST_CONCEPT_ASSERT_FN(void(*)ModelInParens) ^ /usr/local/boost-1.55.0/include/boost/concept_check.hpp:908:11: note: in expansion of macro 'BOOST_CONCEPT_ASSERT' BOOST_CONCEPT_ASSERT((BinaryPredicate<value_compare,value_type_,value_type_>)); ^ /usr/local/boost-1.55.0/include/boost/range/algorithm/equal.hpp: In function 'bool boost::range::equal(const SinglePassRange1&, const SinglePassRange2&)': /usr/local/boost-1.55.0/include/boost/concept/detail/general.hpp:71:20: warning: typedef 'boost_concept_check172' locally defined but not used [-Wunused-local-typedefs] BOOST_PP_CAT(boost_concept_check,__LINE__) ^ /usr/local/boost-1.55.0/include/boost/preprocessor/cat.hpp:29:34: note: in definition of macro 'BOOST_PP_CAT_I' # define BOOST_PP_CAT_I(a, b) a ## b ^ /usr/local/boost-1.55.0/include/boost/concept/detail/general.hpp:71:7: note: in expansion of macro 'BOOST_PP_CAT' BOOST_PP_CAT(boost_concept_check,__LINE__) ^ /usr/local/boost-1.55.0/include/boost/concept/assert.hpp:44:5: note: in expansion of macro 'BOOST_CONCEPT_ASSERT_FN' BOOST_CONCEPT_ASSERT_FN(void(*)ModelInParens) ^ /usr/local/boost-1.55.0/include/boost/range/concepts.hpp:92:45: note: in expansion of macro 'BOOST_CONCEPT_ASSERT' #define BOOST_RANGE_CONCEPT_ASSERT( x ) BOOST_CONCEPT_ASSERT( x ) ^ /usr/local/boost-1.55.0/include/boost/range/algorithm/equal.hpp:172:13: note: in expansion of macro 'BOOST_RANGE_CONCEPT_ASSERT' BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<const SinglePassRange1> )); ^ /usr/local/boost-1.55.0/include/boost/concept/detail/general.hpp:71:20: warning: typedef 'boost_concept_check173' locally defined but not used [-Wunused-local-typedefs] BOOST_PP_CAT(boost_concept_check,__LINE__) ^ /usr/local/boost-1.55.0/include/boost/preprocessor/cat.hpp:29:34: note: in definition of macro 'BOOST_PP_CAT_I' # define BOOST_PP_CAT_I(a, b) a ## b ^ /usr/local/boost-1.55.0/include/boost/concept/detail/general.hpp:71:7: note: in expansion of macro 'BOOST_PP_CAT' BOOST_PP_CAT(boost_concept_check,__LINE__) ^ /usr/local/boost-1.55.0/include/boost/concept/assert.hpp:44:5: note: in expansion of macro 'BOOST_CONCEPT_ASSERT_FN' BOOST_CONCEPT_ASSERT_FN(void(*)ModelInParens) ^ /usr/local/boost-1.55.0/include/boost/range/concepts.hpp:92:45: note: in expansion of macro 'BOOST_CONCEPT_ASSERT' #define BOOST_RANGE_CONCEPT_ASSERT( x ) BOOST_CONCEPT_ASSERT( x ) ^ /usr/local/boost-1.55.0/include/boost/range/algorithm/equal.hpp:173:13: note: in expansion of macro 'BOOST_RANGE_CONCEPT_ASSERT' BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<const SinglePassRange2> )); ^ /usr/local/boost-1.55.0/include/boost/range/algorithm/equal.hpp: In function 'bool boost::range::equal(const SinglePassRange1&, const SinglePassRange2&, BinaryPredicate)': /usr/local/boost-1.55.0/include/boost/concept/detail/general.hpp:71:20: warning: typedef 'boost_concept_check185' locally defined but not used [-Wunused-local-typedefs] BOOST_PP_CAT(boost_concept_check,__LINE__) ^ /usr/local/boost-1.55.0/include/boost/preprocessor/cat.hpp:29:34: note: in definition of macro 'BOOST_PP_CAT_I' # define BOOST_PP_CAT_I(a, b) a ## b ^ /usr/local/boost-1.55.0/include/boost/concept/detail/general.hpp:71:7: note: in expansion of macro 'BOOST_PP_CAT' BOOST_PP_CAT(boost_concept_check,__LINE__) ^ /usr/local/boost-1.55.0/include/boost/concept/assert.hpp:44:5: note: in expansion of macro 'BOOST_CONCEPT_ASSERT_FN' BOOST_CONCEPT_ASSERT_FN(void(*)ModelInParens) ^ /usr/local/boost-1.55.0/include/boost/range/concepts.hpp:92:45: note: in expansion of macro 'BOOST_CONCEPT_ASSERT' #define BOOST_RANGE_CONCEPT_ASSERT( x ) BOOST_CONCEPT_ASSERT( x ) ^ /usr/local/boost-1.55.0/include/boost/range/algorithm/equal.hpp:185:13: note: in expansion of macro 'BOOST_RANGE_CONCEPT_ASSERT' BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<const SinglePassRange1> )); ^ /usr/local/boost-1.55.0/include/boost/concept/detail/general.hpp:71:20: warning: typedef 'boost_concept_check186' locally defined but not used [-Wunused-local-typedefs] BOOST_PP_CAT(boost_concept_check,__LINE__) ^ /usr/local/boost-1.55.0/include/boost/preprocessor/cat.hpp:29:34: note: in definition of macro 'BOOST_PP_CAT_I' # define BOOST_PP_CAT_I(a, b) a ## b ^ /usr/local/boost-1.55.0/include/boost/concept/detail/general.hpp:71:7: note: in expansion of macro 'BOOST_PP_CAT' BOOST_PP_CAT(boost_concept_check,__LINE__) ^ /usr/local/boost-1.55.0/include/boost/concept/assert.hpp:44:5: note: in expansion of macro 'BOOST_CONCEPT_ASSERT_FN' BOOST_CONCEPT_ASSERT_FN(void(*)ModelInParens) ^ /usr/local/boost-1.55.0/include/boost/range/concepts.hpp:92:45: note: in expansion of macro 'BOOST_CONCEPT_ASSERT' #define BOOST_RANGE_CONCEPT_ASSERT( x ) BOOST_CONCEPT_ASSERT( x ) ^ /usr/local/boost-1.55.0/include/boost/range/algorithm/equal.hpp:186:13: note: in expansion of macro 'BOOST_RANGE_CONCEPT_ASSERT' BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<const SinglePassRange2> )); ^ prog.cc: At global scope: prog.cc:15:28: warning: unused parameter 'x' [-Wunused-parameter] SourceEvent f(std::int32_t x) -- Jens Auer | CGI | Software-Engineer CGI (Germany) GmbH & Co. KG Rheinstra?e 95 | 64295 Darmstadt | Germany T: +49 6151 36860 154 jens.auer@cgi.com Unsere Pflichtangaben gem?? ? 35a GmbHG / ?? 161, 125a HGB finden Sie unter de.cgi.com/pflichtangaben. CONFIDENTIALITY NOTICE: Proprietary/Confidential information belonging to CGI Group Inc. and its affiliates may be contained in this message. If you are not a recipient indicated or intended in this message (or responsible for delivery of this message to such person), or you think for any reason that this message may have been addressed to you in error, you may not use or copy or deliver this message to anyone else. In such case, you should destroy this message and are asked to notify the sender by reply e-mail. ________________________________________ Von: Boost [boost-bounces@lists.boost.org]" im Auftrag von "Auer, Jens [jens.auer@cgi.com] Gesendet: Freitag, 15. Januar 2016 07:07 An: boost@lists.boost.org Betreff: Re: [boost] Any-Range containing transformed range fails when compiled with optimizations I have just tested the same code clang 3.7. Here, everything compiles without warnings and works as expected. -- Jens Auer | CGI | Software-Engineer CGI (Germany) GmbH & Co. KG Rheinstra?e 95 | 64295 Darmstadt | Germany T: +49 6151 36860 154 jens.auer@cgi.com Unsere Pflichtangaben gem?? ? 35a GmbHG / ?? 161, 125a HGB finden Sie unter de.cgi.com/pflichtangaben. CONFIDENTIALITY NOTICE: Proprietary/Confidential information belonging to CGI Group Inc. and its affiliates may be contained in this message. If you are not a recipient indicated or intended in this message (or responsible for delivery of this message to such person), or you think for any reason that this message may have been addressed to you in error, you may not use or copy or deliver this message to anyone else. In such case, you should destroy this message and are asked to notify the sender by reply e-mail. ________________________________________ Von: Boost [boost-bounces@lists.boost.org]" im Auftrag von "Auer, Jens [jens.auer@cgi.com] Gesendet: Donnerstag, 14. Januar 2016 21:28 An: boost@lists.boost.org Betreff: [boost] Any-Range containing transformed range fails when compiled with optimizations Hi, I have a program which produces different results based on the compiler options. The program uses a boost::any_range containing a transformed range where the transformation function just returns a new object of a simple struct: #include <vector> #include <boost/range.hpp> #include <boost/range/any_range.hpp> #include <boost/range/adaptor/transformed.hpp> #include <iostream> template<typename T1, typename T2> void ASSERT_EQ(T1 x,T2 y) {assert(x == y);}; struct SourceEvent { std::uint32_t event; void* ptr; }; int main() { using boost::adaptors::transformed; using R = boost::any_range<SourceEvent, boost::forward_traversal_tag, SourceEvent, std::ptrdiff_t>; std::vector<std::int32_t> v(100); R r = v | transformed( [](auto const&) {return SourceEvent{0u, nullptr};} ); auto t = v | transformed( [](auto const&) {return SourceEvent{0u, nullptr};} ); ASSERT_EQ( 100u, boost::size(r) ); ASSERT_EQ( 100u, boost::size(t) ); for (auto const& i: t) { ASSERT_EQ(0u, i.event ); ASSERT_EQ(nullptr, i.ptr); } for (auto const& i: r) { ASSERT_EQ(0u, i.event ); ASSERT_EQ(nullptr, i.ptr); } std::cout << "OK" << std::endl; return 0; } When compiled without optimization, it just prints ok. The same source compiled with optimizations asserts, and prints some interesting warnings: In file included from /usr/local/boost-1.60.0/include/boost/range/detail/any_iterator.hpp:22:0, from /usr/local/boost-1.60.0/include/boost/range/any_range.hpp:17, from prog.cc:3: /usr/local/boost-1.60.0/include/boost/range/detail/any_iterator_wrapper.hpp: In member function 'boost::range_detail::any_forward_iterator_wrapper<WrappedIterator, Reference, Buffer>::reference boost::range_detail::any_forward_iterator_wrapper<WrappedIterator, Reference, Buffer>::dereference() const [with WrappedIterator = boost::iterators::transform_iterator<boost::range_detail::default_constructible_unary_fn_wrapper<main()::<lambda(const auto:1&)>, SourceEvent>, __gnu_cxx::__normal_iterator<int*, std::vector<int> >, boost::iterators::use_default, boost::iterators::use_default>; Reference = SourceEvent; Buffer = boost::any_iterator_buffer<64ul>; boost::range_detail::any_forward_iterator_wrapper<WrappedIterator, Reference, Buffer>::reference = SourceEvent&]': /usr/local/boost-1.60.0/include/boost/range/detail/any_iterator_wrapper.hpp:302:57: warning: function may return address of local variable [-Wreturn-local-addr] return dereference_cast<reference>(*m_it); ^ /usr/local/boost-1.60.0/include/boost/range/detail/any_iterator_wrapper.hpp:302:52: note: declared here return dereference_cast<reference>(*m_it); ^ prog.exe: prog.cc:7: void ASSERT_EQ(T1, T2) [with T1 = unsigned int; T2 = unsigned int]: Assertion `x == y' failed. Aborted The example is compiled with gcc 5.2 and boost 1.60 (http://melpon.org/wandbox/permlink/QF1qyw5bWHKwyKJ8). Is there an error in my code? I would guess that transforming a range into a range of new objects of another type is quite common, so it should work. I am also curious why the warning is only emitted when compiling with optimizations. Best wishes, Jens -- Jens Auer | CGI | Software-Engineer CGI (Germany) GmbH & Co. KG Rheinstra?e 95 | 64295 Darmstadt | Germany T: +49 6151 36860 154 jens.auer@cgi.com<mailto:jens.auer@cgi.com> Unsere Pflichtangaben gem?? ? 35a GmbHG / ?? 161, 125a HGB finden Sie unter de.cgi.com/pflichtangaben<http://de.cgi.com/pflichtangaben>. CONFIDENTIALITY NOTICE: Proprietary/Confidential information belonging to CGI Group Inc. and its affiliates may be contained in this message. If you are not a recipient indicated or intended in this message (or responsible for delivery of this message to such person), or you think for any reason that this message may have been addressed to you in error, you may not use or copy or deliver this message to anyone else. In such case, you should destroy this message and are asked to notify the sender by reply e-mail. _______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost _______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
I've made some more investigations. I modified the program slightly to be able to compile it with older gcc and boost versions to see when it broke. Our project uses gcc 4.9.2 with boost 1.55, but when one of my colleagues compiled it on his local machine with gcc 5.2 and boost 1.59 we started to see the issues. I made a version of the code that's c++03 safe and still exhibits the
On 15-01-16 09:04, Auer, Jens wrote: problem on all clang/gcc versions I own. Sadly I can't download boost 1.55 (sf.net is down) and modular boost doesn't seem to be able to build (headers) in the 1.55 tag... So maybe you can try this for a spin: #include <vector> #include <boost/range.hpp> #include <boost/range/any_range.hpp> #include <boost/range/adaptor/transformed.hpp> #include <iostream> static bool ok = true; struct SourceEvent { unsigned event; void* ptr; }; template <typename R> void test(R const& r) { ok &= (100u == boost::size(r)); for (typename boost::range_iterator<R>::type it = boost::begin(r); it != boost::end(r); ++it) { ok &= (0u == it->event); ok &= (0 == it->ptr); } } struct Xfrm { typedef SourceEvent result_type; SourceEvent operator()(unsigned) const { SourceEvent se = {}; return se; } } xfrm_; SourceEvent xfrm(unsigned) { SourceEvent se = {}; return se; } int main() { using boost::adaptors::transformed; typedef boost::any_range<SourceEvent, boost::forward_traversal_tag/*, SourceEvent, std::ptrdiff_t*/> R; std::vector<int> v(100, 0); test (v | transformed(xfrm_)); test<R>(v | transformed(xfrm_)); if (ok) std::cout << "OK" << std::endl; else std::cout << "FAIL" << std::endl; return ok?0:1; }
I've made some more investigations. I modified the program slightly to be able to compile it with older gcc and boost versions to see when it broke. Our project uses gcc 4.9.2 with boost 1.55, but when one of my colleagues compiled it on his local machine with gcc 5.2 and boost 1.59 we started to see the issues. I made a version of the code that's c++03 safe and still exhibits the
Hi, I had to slightly modify the code to make it work with boost 1.55. I then ran your examples through some combinations of gcc/boost using the online compiler http://melpon.org/wandbox/. You can choose the gcc version and the boost version the compiler will use. Here are the results: compiler boost result gcc 4.9.2 1.55 ok gcc 4.9.2 1.56 fail gcc 4.9.2 1.60 fail gcc 5.2.0 1.55 ok gcc 5.2.0 1.56 fail clang 3.7 1.60 fail clang 3.7 1.55 ok clang 3.7 1.56 fail Boost 1.55 consistenly work with gcc and clang. Starting with Boost 1.56, it consistently fails. Best wishes, Jens -- Jens Auer | CGI | Software-Engineer CGI (Germany) GmbH & Co. KG Rheinstraße 95 | 64295 Darmstadt | Germany T: +49 6151 36860 154 jens.auer@cgi.com Unsere Pflichtangaben gemäß § 35a GmbHG / §§ 161, 125a HGB finden Sie unter de.cgi.com/pflichtangaben. CONFIDENTIALITY NOTICE: Proprietary/Confidential information belonging to CGI Group Inc. and its affiliates may be contained in this message. If you are not a recipient indicated or intended in this message (or responsible for delivery of this message to such person), or you think for any reason that this message may have been addressed to you in error, you may not use or copy or deliver this message to anyone else. In such case, you should destroy this message and are asked to notify the sender by reply e-mail. ________________________________________ Von: Boost [boost-bounces@lists.boost.org]" im Auftrag von "Seth [bugs@sehe.nl] Gesendet: Freitag, 15. Januar 2016 14:08 An: boost@lists.boost.org Betreff: Re: [boost] Any-Range containing transformed range fails when compiled with optimizations On 15-01-16 09:04, Auer, Jens wrote: problem on all clang/gcc versions I own. Sadly I can't download boost 1.55 (sf.net is down) and modular boost doesn't seem to be able to build (headers) in the 1.55 tag... So maybe you can try this for a spin: #include <vector> #include <boost/range.hpp> #include <boost/range/any_range.hpp> #include <boost/range/adaptor/transformed.hpp> #include <iostream> static bool ok = true; struct SourceEvent { unsigned event; void* ptr; }; template <typename R> void test(R const& r) { ok &= (100u == boost::size(r)); for (typename boost::range_iterator<R>::type it = boost::begin(r); it != boost::end(r); ++it) { ok &= (0u == it->event); ok &= (0 == it->ptr); } } struct Xfrm { typedef SourceEvent result_type; SourceEvent operator()(unsigned) const { SourceEvent se = {}; return se; } } xfrm_; SourceEvent xfrm(unsigned) { SourceEvent se = {}; return se; } int main() { using boost::adaptors::transformed; typedef boost::any_range<SourceEvent, boost::forward_traversal_tag/*, SourceEvent, std::ptrdiff_t*/> R; std::vector<int> v(100, 0); test (v | transformed(xfrm_)); test<R>(v | transformed(xfrm_)); if (ok) std::cout << "OK" << std::endl; else std::cout << "FAIL" << std::endl; return ok?0:1; } _______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Hi, after some thinking, I have come up with a theory what is happening. I think it is one of the cases where the iterator is not really a standard-conform iterator type because dereferencing it does not return a real reference. The warning message points to the derefernce funtion of any_iterator. Could it be that any_iterator only works with standard-conform real iterators? If so, it would be nice to prevent combining it with range adaptors with a static if, e.g. by adding static_assert( std::is_reference< decltype(*m_it) >::value, "Dereferencing must return a reference. Proxy objects are not supported") to any_single_pass_iterator_wrapper::dereference() in boost/range/detail/any_iterator_wrapper.hpp, l. 302. Cheers, Jens Auer -- Jens Auer | CGI | Software-Engineer CGI (Germany) GmbH & Co. KG Rheinstraße 95 | 64295 Darmstadt | Germany T: +49 6151 36860 154 jens.auer@cgi.com Unsere Pflichtangaben gemäß § 35a GmbHG / §§ 161, 125a HGB finden Sie unter de.cgi.com/pflichtangaben. CONFIDENTIALITY NOTICE: Proprietary/Confidential information belonging to CGI Group Inc. and its affiliates may be contained in this message. If you are not a recipient indicated or intended in this message (or responsible for delivery of this message to such person), or you think for any reason that this message may have been addressed to you in error, you may not use or copy or deliver this message to anyone else. In such case, you should destroy this message and are asked to notify the sender by reply e-mail. ________________________________________ Von: Boost [boost-bounces@lists.boost.org]" im Auftrag von "Auer, Jens [jens.auer@cgi.com] Gesendet: Donnerstag, 14. Januar 2016 21:28 An: boost@lists.boost.org Betreff: [boost] Any-Range containing transformed range fails when compiled with optimizations Hi, I have a program which produces different results based on the compiler options. The program uses a boost::any_range containing a transformed range where the transformation function just returns a new object of a simple struct: #include <vector> #include <boost/range.hpp> #include <boost/range/any_range.hpp> #include <boost/range/adaptor/transformed.hpp> #include <iostream> template<typename T1, typename T2> void ASSERT_EQ(T1 x,T2 y) {assert(x == y);}; struct SourceEvent { std::uint32_t event; void* ptr; }; int main() { using boost::adaptors::transformed; using R = boost::any_range<SourceEvent, boost::forward_traversal_tag, SourceEvent, std::ptrdiff_t>; std::vector<std::int32_t> v(100); R r = v | transformed( [](auto const&) {return SourceEvent{0u, nullptr};} ); auto t = v | transformed( [](auto const&) {return SourceEvent{0u, nullptr};} ); ASSERT_EQ( 100u, boost::size(r) ); ASSERT_EQ( 100u, boost::size(t) ); for (auto const& i: t) { ASSERT_EQ(0u, i.event ); ASSERT_EQ(nullptr, i.ptr); } for (auto const& i: r) { ASSERT_EQ(0u, i.event ); ASSERT_EQ(nullptr, i.ptr); } std::cout << "OK" << std::endl; return 0; } When compiled without optimization, it just prints ok. The same source compiled with optimizations asserts, and prints some interesting warnings: In file included from /usr/local/boost-1.60.0/include/boost/range/detail/any_iterator.hpp:22:0, from /usr/local/boost-1.60.0/include/boost/range/any_range.hpp:17, from prog.cc:3: /usr/local/boost-1.60.0/include/boost/range/detail/any_iterator_wrapper.hpp: In member function 'boost::range_detail::any_forward_iterator_wrapper<WrappedIterator, Reference, Buffer>::reference boost::range_detail::any_forward_iterator_wrapper<WrappedIterator, Reference, Buffer>::dereference() const [with WrappedIterator = boost::iterators::transform_iterator<boost::range_detail::default_constructible_unary_fn_wrapper<main()::<lambda(const auto:1&)>, SourceEvent>, __gnu_cxx::__normal_iterator<int*, std::vector<int> >, boost::iterators::use_default, boost::iterators::use_default>; Reference = SourceEvent; Buffer = boost::any_iterator_buffer<64ul>; boost::range_detail::any_forward_iterator_wrapper<WrappedIterator, Reference, Buffer>::reference = SourceEvent&]': /usr/local/boost-1.60.0/include/boost/range/detail/any_iterator_wrapper.hpp:302:57: warning: function may return address of local variable [-Wreturn-local-addr] return dereference_cast<reference>(*m_it); ^ /usr/local/boost-1.60.0/include/boost/range/detail/any_iterator_wrapper.hpp:302:52: note: declared here return dereference_cast<reference>(*m_it); ^ prog.exe: prog.cc:7: void ASSERT_EQ(T1, T2) [with T1 = unsigned int; T2 = unsigned int]: Assertion `x == y' failed. Aborted The example is compiled with gcc 5.2 and boost 1.60 (http://melpon.org/wandbox/permlink/QF1qyw5bWHKwyKJ8). Is there an error in my code? I would guess that transforming a range into a range of new objects of another type is quite common, so it should work. I am also curious why the warning is only emitted when compiling with optimizations. Best wishes, Jens -- Jens Auer | CGI | Software-Engineer CGI (Germany) GmbH & Co. KG Rheinstraße 95 | 64295 Darmstadt | Germany T: +49 6151 36860 154 jens.auer@cgi.com<mailto:jens.auer@cgi.com> Unsere Pflichtangaben gemäß § 35a GmbHG / §§ 161, 125a HGB finden Sie unter de.cgi.com/pflichtangaben<http://de.cgi.com/pflichtangaben>. CONFIDENTIALITY NOTICE: Proprietary/Confidential information belonging to CGI Group Inc. and its affiliates may be contained in this message. If you are not a recipient indicated or intended in this message (or responsible for delivery of this message to such person), or you think for any reason that this message may have been addressed to you in error, you may not use or copy or deliver this message to anyone else. In such case, you should destroy this message and are asked to notify the sender by reply e-mail. _______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
I am sorry if it's obvious, but there is simple workaround: add 'const' to third template argument of boost::any_range. [using R = boost::any_range<SourceEvent, boost::forward_traversal_tag, const SourceEvent, std::ptrdiff_t>;] In that case boost::any_forward_iterator_wrapper<...>::reference become 'SourceEvent' instead of 'SourceEvent &', and returning address of local variable will be prevented. On Thu, Jan 14, 2016 at 11:28 PM, Auer, Jens <jens.auer@cgi.com> wrote:
Hi,
I have a program which produces different results based on the compiler options. The program uses a boost::any_range containing a transformed range where the transformation function just returns a new object of a simple struct: #include <vector> #include <boost/range.hpp> #include <boost/range/any_range.hpp> #include <boost/range/adaptor/transformed.hpp> #include <iostream>
template<typename T1, typename T2> void ASSERT_EQ(T1 x,T2 y) {assert(x == y);};
struct SourceEvent { std::uint32_t event; void* ptr; };
int main() { using boost::adaptors::transformed;
using R = boost::any_range<SourceEvent, boost::forward_traversal_tag, SourceEvent, std::ptrdiff_t>; std::vector<std::int32_t> v(100); R r = v | transformed( [](auto const&) {return SourceEvent{0u, nullptr};} ); auto t = v | transformed( [](auto const&) {return SourceEvent{0u, nullptr};} );
ASSERT_EQ( 100u, boost::size(r) ); ASSERT_EQ( 100u, boost::size(t) );
for (auto const& i: t) { ASSERT_EQ(0u, i.event ); ASSERT_EQ(nullptr, i.ptr); }
for (auto const& i: r) { ASSERT_EQ(0u, i.event ); ASSERT_EQ(nullptr, i.ptr); }
std::cout << "OK" << std::endl;
return 0; }
When compiled without optimization, it just prints ok. The same source compiled with optimizations asserts, and prints some interesting warnings:
In file included from /usr/local/boost-1.60.0/include/boost/range/detail/any_iterator.hpp:22:0, from /usr/local/boost-1.60.0/include/boost/range/any_range.hpp:17, from prog.cc:3: /usr/local/boost-1.60.0/include/boost/range/detail/any_iterator_wrapper.hpp: In member function 'boost::range_detail::any_forward_iterator_wrapper<WrappedIterator, Reference, Buffer>::reference boost::range_detail::any_forward_iterator_wrapper<WrappedIterator, Reference, Buffer>::dereference() const [with WrappedIterator = boost::iterators::transform_iterator<boost::range_detail::default_constructible_unary_fn_wrapper<main()::<lambda(const auto:1&)>, SourceEvent>, __gnu_cxx::__normal_iterator<int*, std::vector<int> >, boost::iterators::use_default, boost::iterators::use_default>; Reference = SourceEvent; Buffer = boost::any_iterator_buffer<64ul>; boost::range_detail::any_forward_iterator_wrapper<WrappedIterator, Reference, Buffer>::reference = SourceEvent&]': /usr/local/boost-1.60.0/include/boost/range/detail/any_iterator_wrapper.hpp:302:57: warning: function may return address of local variable [-Wreturn-local-addr] return dereference_cast<reference>(*m_it); ^ /usr/local/boost-1.60.0/include/boost/range/detail/any_iterator_wrapper.hpp:302:52: note: declared here return dereference_cast<reference>(*m_it); ^
prog.exe: prog.cc:7: void ASSERT_EQ(T1, T2) [with T1 = unsigned int; T2 = unsigned int]: Assertion `x == y' failed.
Aborted
The example is compiled with gcc 5.2 and boost 1.60 ( http://melpon.org/wandbox/permlink/QF1qyw5bWHKwyKJ8). Is there an error in my code? I would guess that transforming a range into a range of new objects of another type is quite common, so it should work. I am also curious why the warning is only emitted when compiling with optimizations.
Best wishes, Jens
-- Jens Auer | CGI | Software-Engineer CGI (Germany) GmbH & Co. KG Rheinstraße 95 | 64295 Darmstadt | Germany T: +49 6151 36860 154 jens.auer@cgi.com<mailto:jens.auer@cgi.com> Unsere Pflichtangaben gemäß § 35a GmbHG / §§ 161, 125a HGB finden Sie unter de.cgi.com/pflichtangaben<http://de.cgi.com/pflichtangaben>.
CONFIDENTIALITY NOTICE: Proprietary/Confidential information belonging to CGI Group Inc. and its affiliates may be contained in this message. If you are not a recipient indicated or intended in this message (or responsible for delivery of this message to such person), or you think for any reason that this message may have been addressed to you in error, you may not use or copy or deliver this message to anyone else. In such case, you should destroy this message and are asked to notify the sender by reply e-mail.
_______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
-- Андрей Давыдов.
Hi, since I am pretty sure that it is boost issue now, I searched the bug database. It is a known bug (Ticket #10493, https://svn.boost.org/trac/boost/ticket/10493). The const reference is also the proposed work-around. Best wishes, Jens -- Jens Auer | CGI | Software-Engineer CGI (Germany) GmbH & Co. KG Rheinstraße 95 | 64295 Darmstadt | Germany T: +49 6151 36860 154 jens.auer@cgi.com Unsere Pflichtangaben gemäß § 35a GmbHG / §§ 161, 125a HGB finden Sie unter de.cgi.com/pflichtangaben. CONFIDENTIALITY NOTICE: Proprietary/Confidential information belonging to CGI Group Inc. and its affiliates may be contained in this message. If you are not a recipient indicated or intended in this message (or responsible for delivery of this message to such person), or you think for any reason that this message may have been addressed to you in error, you may not use or copy or deliver this message to anyone else. In such case, you should destroy this message and are asked to notify the sender by reply e-mail. ________________________________________ Von: Boost [boost-bounces@lists.boost.org]" im Auftrag von "Andrey Davydov [andrey.a.davydov@gmail.com] Gesendet: Samstag, 16. Januar 2016 18:44 An: boost@lists.boost.org Betreff: Re: [boost] Any-Range containing transformed range fails when compiled with optimizations I am sorry if it's obvious, but there is simple workaround: add 'const' to third template argument of boost::any_range. [using R = boost::any_range<SourceEvent, boost::forward_traversal_tag, const SourceEvent, std::ptrdiff_t>;] In that case boost::any_forward_iterator_wrapper<...>::reference become 'SourceEvent' instead of 'SourceEvent &', and returning address of local variable will be prevented. On Thu, Jan 14, 2016 at 11:28 PM, Auer, Jens <jens.auer@cgi.com> wrote:
Hi,
I have a program which produces different results based on the compiler options. The program uses a boost::any_range containing a transformed range where the transformation function just returns a new object of a simple struct: #include <vector> #include <boost/range.hpp> #include <boost/range/any_range.hpp> #include <boost/range/adaptor/transformed.hpp> #include <iostream>
template<typename T1, typename T2> void ASSERT_EQ(T1 x,T2 y) {assert(x == y);};
struct SourceEvent { std::uint32_t event; void* ptr; };
int main() { using boost::adaptors::transformed;
using R = boost::any_range<SourceEvent, boost::forward_traversal_tag, SourceEvent, std::ptrdiff_t>; std::vector<std::int32_t> v(100); R r = v | transformed( [](auto const&) {return SourceEvent{0u, nullptr};} ); auto t = v | transformed( [](auto const&) {return SourceEvent{0u, nullptr};} );
ASSERT_EQ( 100u, boost::size(r) ); ASSERT_EQ( 100u, boost::size(t) );
for (auto const& i: t) { ASSERT_EQ(0u, i.event ); ASSERT_EQ(nullptr, i.ptr); }
for (auto const& i: r) { ASSERT_EQ(0u, i.event ); ASSERT_EQ(nullptr, i.ptr); }
std::cout << "OK" << std::endl;
return 0; }
When compiled without optimization, it just prints ok. The same source compiled with optimizations asserts, and prints some interesting warnings:
In file included from /usr/local/boost-1.60.0/include/boost/range/detail/any_iterator.hpp:22:0, from /usr/local/boost-1.60.0/include/boost/range/any_range.hpp:17, from prog.cc:3: /usr/local/boost-1.60.0/include/boost/range/detail/any_iterator_wrapper.hpp: In member function 'boost::range_detail::any_forward_iterator_wrapper<WrappedIterator, Reference, Buffer>::reference boost::range_detail::any_forward_iterator_wrapper<WrappedIterator, Reference, Buffer>::dereference() const [with WrappedIterator = boost::iterators::transform_iterator<boost::range_detail::default_constructible_unary_fn_wrapper<main()::<lambda(const auto:1&)>, SourceEvent>, __gnu_cxx::__normal_iterator<int*, std::vector<int> >, boost::iterators::use_default, boost::iterators::use_default>; Reference = SourceEvent; Buffer = boost::any_iterator_buffer<64ul>; boost::range_detail::any_forward_iterator_wrapper<WrappedIterator, Reference, Buffer>::reference = SourceEvent&]': /usr/local/boost-1.60.0/include/boost/range/detail/any_iterator_wrapper.hpp:302:57: warning: function may return address of local variable [-Wreturn-local-addr] return dereference_cast<reference>(*m_it); ^ /usr/local/boost-1.60.0/include/boost/range/detail/any_iterator_wrapper.hpp:302:52: note: declared here return dereference_cast<reference>(*m_it); ^
prog.exe: prog.cc:7: void ASSERT_EQ(T1, T2) [with T1 = unsigned int; T2 = unsigned int]: Assertion `x == y' failed.
Aborted
The example is compiled with gcc 5.2 and boost 1.60 ( http://melpon.org/wandbox/permlink/QF1qyw5bWHKwyKJ8). Is there an error in my code? I would guess that transforming a range into a range of new objects of another type is quite common, so it should work. I am also curious why the warning is only emitted when compiling with optimizations.
Best wishes, Jens
-- Jens Auer | CGI | Software-Engineer CGI (Germany) GmbH & Co. KG Rheinstraße 95 | 64295 Darmstadt | Germany T: +49 6151 36860 154 jens.auer@cgi.com<mailto:jens.auer@cgi.com> Unsere Pflichtangaben gemäß § 35a GmbHG / §§ 161, 125a HGB finden Sie unter de.cgi.com/pflichtangaben<http://de.cgi.com/pflichtangaben>.
CONFIDENTIALITY NOTICE: Proprietary/Confidential information belonging to CGI Group Inc. and its affiliates may be contained in this message. If you are not a recipient indicated or intended in this message (or responsible for delivery of this message to such person), or you think for any reason that this message may have been addressed to you in error, you may not use or copy or deliver this message to anyone else. In such case, you should destroy this message and are asked to notify the sender by reply e-mail.
_______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
-- Андрей Давыдов. _______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
participants (3)
-
Andrey Davydov
-
Auer, Jens
-
Seth