Opened 15 years ago
Closed 12 years ago
#1581 closed Bugs (worksforme)
Boost.MultiArray: Resizing bug if the index is not 0-based
| Reported by: | Owned by: | Ronald Garcia | |
|---|---|---|---|
| Milestone: | Boost 1.36.0 | Component: | multi_array |
| Version: | Boost 1.34.1 | Severity: | Problem |
| Keywords: | multiarray resize reindex | Cc: |
Description
I find that a boost::multi_array will crash when calling to resize() with non 0-based indexes. The implementation seems have problem if the array is not 0-based.
Please see the following code:
#include <boost/multi_array.hpp>
#include <boost/array.hpp>
int main(int,char*[])
{
typedef boost::multi_array<int, 2> marray;
marray A(boost::extents[5][5]);
boost::array<marray::index, 2> bases;
bases[0] = 2;
bases[1] = 3;
A.reindex(bases);
// bases[0] = 0;
// bases[1] = 0;
// A.reindex(bases);
A.resize(boost::extents[7][7]);
bases[0] = 2;
bases[1] = 3;
A.reindex(bases);
return 0;
}
The above program will get crash unless you uncomment the 3 lines that re-index bases to 0.
Note:
See TracTickets
for help on using tickets.

This code passes for me with GCC 4.1.2, even under Valgrind.