File: derrick-bass-1.cpp

package info (click to toggle)
blitz%2B%2B 1%3A0.9-1.2
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 12,604 kB
  • ctags: 12,925
  • sloc: cpp: 97,336; sh: 8,438; fortran: 1,208; makefile: 652; f90: 596
file content (62 lines) | stat: -rw-r--r-- 1,186 bytes parent folder | download | duplicates (10)
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>

BZ_USING_NAMESPACE(std)
BZ_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;
}