Boost logo

Boost Users :

Subject: [Boost-users] [multi_array] Assertion when resizing empty array
From: John Reid (j.reid_at_[hidden])
Date: 2009-07-22 06:10:42


Resizing an empty array no longer seems to work. My code worked fine
with boost 1.38, now it causes an assertion with the latest boost trunk
from svn. The code is:

#include <boost/multi_array.hpp>

int
main( int argc, char * argv[] ) {
        boost::multi_array< double, 2 > a;
        a.resize( boost::extents[2][3] );
        return 0;
}

The assertion is:
multi_array_resize:
/home/john/Dev/ThirdParty/boost/boost-trunk/boost/multi_array/base.hpp:446:
ArrayRef boost::detail::multi_array::multi_array_impl_base<T,
NumDims>::generate_array_view(boost::type<Reference>, const
boost::detail::multi_array::index_gen<NumDims, NDims>&, const typename
boost::detail::multi_array::associated_types<T, mpl_::size_t<NumDims>
>::size_type*, const typename
boost::detail::multi_array::associated_types<T, mpl_::size_t<NumDims>
>::index*, const typename
boost::detail::multi_array::associated_types<T, mpl_::size_t<NumDims>
>::index*, TPtr) const [with ArrayRef =
boost::detail::multi_array::multi_array_view<double, 2ul>, int NDims =
2, TPtr = double*, T = double, long unsigned int NumDims = 2ul]:
Assertion `index_bases[n] <= start && start <
index_bases[n]+index(extents[n])' failed.
Aborted

My compiler is:
john_at_john-dell:~/Dev/MyProjects/Bio/hmm$ gcc -v
Using built-in specs.
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu
4.3.3-5ubuntu4' --with-bugurl=file:///usr/share/doc/gcc-4.3/README.Bugs
--enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr
--enable-shared --with-system-zlib --libexecdir=/usr/lib
--without-included-gettext --enable-threads=posix --enable-nls
--with-gxx-include-dir=/usr/include/c++/4.3 --program-suffix=-4.3
--enable-clocale=gnu --enable-libstdcxx-debug --enable-objc-gc
--enable-mpfr --with-tune=generic --enable-checking=release
--build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 4.3.3 (Ubuntu 4.3.3-5ubuntu4)

I updated from svn today.

I think the code creates a view on the old data in order to retain it.
The assertion happens because this view is empty.

Regards,
John.


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net