Opened 13 years ago

Last modified 12 years ago

#3077 assigned Bugs

Reverse iterator compile-time bug in multi_array

Reported by: John Reid <john.reid@…> Owned by: Jeremiah Willcock
Milestone: Boost 1.40.0 Component: multi_array
Version: Boost 1.38.0 Severity: Problem
Keywords: Cc:

Description

I'm having some trouble iterating over a 2-dimensional multi_array in reverse order. I'm using boost 1.38 with gcc-4.2.4 and the following code won't compile with the error given below:

#include <boost/multi_array.hpp>

template< typename It >
void
iterate_over( It begin, It end )
{
    while( end != begin ) {
        begin->end() - begin->begin();
        ++begin;
    }
}

void
test()
{
    boost::multi_array< double, 2 > m;
    iterate_over( m.begin(), m.end() );   // works fine
    iterate_over( m.rbegin(), m.rend() ); // causes error
}

This looks to me like a bug in the implementation of the reverse iterator for multi_array. Am I wrong? It is only a problem when iterator::operator-> is used. The (*begin). notation works fine.

/home/john/Dev/ThirdParty/boost/boost_1_38_0/boost/iterator/iterator_facade.hpp: In static member function ‘static typename boost::mpl::if_<boost::is_reference<Reference>, Pointer, boost::detail::operator_arrow_proxy<ValueType> >::type boost::detail::operator_arrow_result<ValueType, Reference, Pointer>::make(Reference) [with ValueType = boost::multi_array<double, 1ul, std::allocator<double> >, Reference = boost::detail::multi_array::sub_array<double, 1ul>, Pointer = boost::multi_array<double, 1ul, std::allocator<double> >*]’: /home/john/Dev/ThirdParty/boost/boost_1_38_0/boost/iterator/iterator_facade.hpp:648: instantiated from ‘typename boost::detail::operator_arrow_result<typename boost::detail::iterator_facade_types<Value, CategoryOrTraversal, Reference, Difference>::value_type, Reference, typename boost::detail::iterator_facade_types<Value, CategoryOrTraversal, Reference, Difference>::pointer>::type boost::iterator_facade<I, V, TC, R, D>::operator->() const [with Derived = boost::reverse_iterator<boost::detail::multi_array::array_iterator<double, double*, mpl_::size_t<2ul>, boost::detail::multi_array::sub_array<double, 1ul> > >, Value = boost::multi_array<double, 1ul, std::allocator<double> >, CategoryOrTraversal = boost::detail::iterator_category_with_traversal<std::input_iterator_tag, boost::random_access_traversal_tag>, Reference = boost::detail::multi_array::sub_array<double, 1ul>, Difference = long int]’ src/sandbox/seqan_sandbox.cpp:12: instantiated from ‘void iterate_over(It, It) [with It = boost::reverse_iterator<boost::detail::multi_array::array_iterator<double, double*, mpl_::size_t<2ul>, boost::detail::multi_array::sub_array<double, 1ul> > >]’ src/sandbox/seqan_sandbox.cpp:22: instantiated from here /home/john/Dev/ThirdParty/boost/boost_1_38_0/boost/iterator/iterator_facade.hpp:326: error: no matching function for call to ‘implicit_cast(boost::detail::multi_array::sub_array<double, 1ul>*)’

Change History (2)

comment:1 by John Reid <j.reid@…>, 13 years ago

Just wanted to correct my email address: j.reid@…

comment:2 by Jeremiah Willcock, 12 years ago

Owner: changed from Ronald Garcia to Jeremiah Willcock
Status: newassigned

This is unrelated to reverse_iterator; the forward direction of the traversal fails to compile for me for the same reason. The patch to Boost.Iterator in ticket #4313 (along with the change to MultiArray in r62604) will fix this.

Note: See TracTickets for help on using tickets.