1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
|
/*
* Bug found by Derrick Bass <derrick@tapir.caltech.edu>. In
* ../blitz/arrayeval.cc, evaluateWithStackTraversal1(), there
* was an error in unrolling loops with common strides which caused
* the wrong loop bounds to be chosen. As a result, more elements
* were overwritten than were supposed to be. The appropriate
* fix was changing this line:
*
* int n1 = (ubound & 3) * commonStride;
*
* to
*
* int n1 = (length(firstRank) & 3) * commonStride;
*
* -- TV 980402
*/
#include "testsuite.h"
#include <blitz/tuning.h>
#define BZ_ARRAY_STACK_TRAVERSAL_UNROLL
#define BZ_ARRAY_EXPR_USE_COMMON_STRIDE
#include <blitz/array.h>
using namespace std;
using namespace blitz;
int assignCount = 0;
class ddouble {
double d;
public:
ddouble() : d(0) { }
ddouble(double _d) : d(_d) { }
ddouble& operator=(double _d) {
d = _d;
return *this; }
ddouble& operator=(ddouble _d) {
d = _d.d;
++assignCount;
return *this; }
operator double() { return d; }
};
int main()
{
Range fr(0,11);
Range bw2(0,2);
Array<ddouble, 2> D(bw2,fr);
D(bw2, 11) = 0;
BZTEST(assignCount == 3);
return 0;
}
|