Opened 15 years ago

Closed 15 years ago

#1127 closed Bugs (fixed)

multi_array views do not handle negative strides correctly

Reported by: news@… Owned by: Ronald Garcia
Milestone: To Be Determined Component: multi_array
Version: Severity: Problem
Keywords: Cc:

Description

Discovered in 1.33.1, but the code appears to be unchanged in 1.34.1.

The attached test case fails. Compiling with FUDGED_RANGE causes the test case to work, but it shouldn't. The problem appears to be due to generate_array_view in boost/multi_array/base.hpp; it does not correctly handle negative strides.

"len" is incorrectly calculated in the following code, when stride (and hence index_factor) is negative:

index index_factor = current_range.stride(); index len = (finish - start + (index_factor - 1)) / index_factor;

I was initially unsure as to whether negative strides were supported, but it is clear from other code in base.hpp that stride sign is carefully handled, so I it should be in the view.

Phil Richards

Attachments (1)

test_multi_array_view_neg_stride.cpp (1.1 KB ) - added by news@… 15 years ago.
Test case for mutli_array view with negative stride

Download all attachments as: .zip

Change History (2)

by news@…, 15 years ago

Test case for mutli_array view with negative stride

comment:1 by Ronald Garcia, 15 years ago

Resolution: fixed
Status: newclosed

(In [38482]) Fixes #1127 array views were not handling negative strides properly. Thanks to Phil Richards for pointing that out.

Note: See TracTickets for help on using tickets.