Boost logo

Boost :

Subject: [boost] [repost][multiarray] Bug with boost::detail::multi_array::array_iterator on MSVC 2010RC?
From: Jesse Perla (jesseperla_at_[hidden])
Date: 2010-03-12 11:05:36


Sorry for the repost, but I am pretty sure this is a bug with the MSVC
standard library integration to multi_array. It could also be related to
boost::iterator

The following code worked on MSVC 2008, Intel 11.1 on Windows, and MinGW,
... but is failing to compile on the MSVC 2010RC.
I tested this against boost 1.42 and the boost trunk from SVN.

#pragma warning(disable:4996) //Tough to see errors otherwise.
#include <boost/multi_array.hpp>
int main(int argc, char* argv[])
{
boost::multi_array<double, 3> f_values(boost::extents[5][6][7]); //A
boost::multidimensional object
 boost::detail::multi_array::sub_array<double, 2> sub_f = f_values[2];
//Works
boost::multi_array<double, 2> sub_f2 = f_values[2]; //Fails on MSVC10, works
on all others
}

//////////////////
The problem here is with the constructor in multi_array.hpp around line 334.
 It uses an std::copy,
However, if I replace the:
std::copy(rhs.begin(),rhs.end(),this->begin());

with the (godawful) direct iteration:

auto p_rhs = rhs.begin();
auto p_this = this->begin();
 while(p_rhs < rhs.end())
{
*p_this = *p_rhs;
 ++p_rhs;
++p_this;
}

Things compile fine.

Also note, that this same problem with the std::copy happens in pretty much
every other constructor/place it is used in this library. (i.e. all over the
place, so this 'hack' is pretty useless).

It appears to me that the MSVC's STD implementation isn't finding a match a
std::copy overload impl with the iterators as:

Input iterator as:
boost::detail::multi_array::array_iterator<double,const double
*,boost::mpl::size_t<2>,boost::detail::multi_array::const_sub_array<double,1>>

Output iterator as:
boost::detail::multi_array::array_iterator<double,double
*,boost::mpl::size_t<2>,boost::detail::multi_array::sub_array<double,1>>,

I have attached my test files. Any ideas or patches would be appreciated






Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk