gravatar
alpar (Alpar Juttner)
alpar@cs.elte.hu
Avoid bit operator precedence warning with gcc-4.3 Some of these warnings are actually revealed real bugs
0 2 0
default
2 files changed with 24 insertions and 23 deletions:
↑ Collapse diff ↑
Show white space 6 line context
... ...
@@ -52,3 +52,3 @@
52 52
      _node_num = 1 << dim;
53
      _edge_num = dim * (1 << dim-1);
53
      _edge_num = dim * (1 << (dim-1));
54 54
    }
... ...
@@ -78,5 +78,5 @@
78 78
    Node u(Edge edge) const {
79
      int base = edge._id & ((1 << _dim-1) - 1);
80
      int k = edge._id >> _dim-1;
81
      return ((base >> k) << k+1) | (base & ((1 << k) - 1));
79
      int base = edge._id & ((1 << (_dim-1)) - 1);
80
      int k = edge._id >> (_dim-1);
81
      return ((base >> k) << (k+1)) | (base & ((1 << k) - 1));
82 82
    }
... ...
@@ -84,5 +84,5 @@
84 84
    Node v(Edge edge) const {
85
      int base = edge._id & ((1 << _dim-1) - 1);
86
      int k = edge._id >> _dim-1;
87
      return ((base >> k) << k+1) | (base & ((1 << k) - 1)) | (1 << k);
85
      int base = edge._id & ((1 << (_dim-1)) - 1);
86
      int k = edge._id >> (_dim-1);
87
      return ((base >> k) << (k+1)) | (base & ((1 << k) - 1)) | (1 << k);
88 88
    }
... ...
@@ -107,3 +107,4 @@
107 107
      if (d >> 1 != 0) return INVALID;
108
      return (k << _dim-1) | ((u._id >> k+1) << k) | (u._id & ((1 << k) - 1));
108
      return (k << (_dim-1)) | ((u._id >> (k+1)) << k) |
109
        (u._id & ((1 << k) - 1));
109 110
    }
... ...
@@ -113,3 +114,3 @@
113 114
      if (edge == INVALID) return INVALID;
114
      int k = edge._id >> _dim-1;
115
      int k = edge._id >> (_dim-1);
115 116
      return ((u._id >> k) & 1) == 1 ? edge._id << 1 : (edge._id << 1) | 1;
... ...
@@ -196,6 +197,6 @@
196 197
      Node n = dir ? u(edge) : v(edge);
197
      int k = (edge._id >> _dim-1) + 1;
198
      int k = (edge._id >> (_dim-1)) + 1;
198 199
      if (k < _dim) {
199
        edge._id = (k << _dim-1) |
200
                   ((n._id >> k+1) << k) | (n._id & ((1 << k) - 1));
200
        edge._id = (k << (_dim-1)) |
201
          ((n._id >> (k+1)) << k) | (n._id & ((1 << k) - 1));
201 202
        dir = ((n._id >> k) & 1) == 0;
... ...
@@ -215,4 +216,4 @@
215 216
      if (k < _dim) {
216
        arc._id = (k << _dim-1) |
217
                  ((n._id >> k+1) << k) | (n._id & ((1 << k) - 1));
217
        arc._id = (k << (_dim-1)) |
218
          ((n._id >> (k+1)) << k) | (n._id & ((1 << k) - 1));
218 219
        arc._id = (arc._id << 1) | (~(n._id >> k) & 1);
... ...
@@ -231,4 +232,4 @@
231 232
      if (k < _dim) {
232
        arc._id = (k << _dim-1) |
233
                  ((n._id >> k+1) << k) | (n._id & ((1 << k) - 1));
233
        arc._id = (k << (_dim-1)) |
234
          ((n._id >> (k+1)) << k) | (n._id & ((1 << k) - 1));
234 235
        arc._id = (arc._id << 1) | ((n._id >> k) & 1);
... ...
@@ -256,3 +257,3 @@
256 257
    int dimension(Edge edge) const {
257
      return edge._id >> _dim-1;
258
      return edge._id >> (_dim-1);
258 259
    }
Ignore white space 6 line context
... ...
@@ -323,3 +323,3 @@
323 323
  checkGraphNodeList(G, 1 << dim);
324
  checkGraphEdgeList(G, dim * (1 << dim-1));
324
  checkGraphEdgeList(G, dim * (1 << (dim-1)));
325 325
  checkGraphArcList(G, dim * (1 << dim));
... ...
@@ -332,5 +332,5 @@
332 332
      check( (G.u(e) == n &&
333
              G.id(G.v(e)) == G.id(n) ^ (1 << G.dimension(e))) ||
333
              G.id(G.v(e)) == (G.id(n) ^ (1 << G.dimension(e)))) ||
334 334
             (G.v(e) == n &&
335
              G.id(G.u(e)) == G.id(n) ^ (1 << G.dimension(e))),
335
              G.id(G.u(e)) == (G.id(n) ^ (1 << G.dimension(e)))),
336 336
             "Wrong edge or wrong dimension");
... ...
@@ -341,3 +341,3 @@
341 341
      check(G.source(a) == n &&
342
            G.id(G.target(a)) == G.id(n) ^ (1 << G.dimension(a)),
342
            G.id(G.target(a)) == (G.id(n) ^ (1 << G.dimension(a))),
343 343
            "Wrong arc or wrong dimension");
... ...
@@ -348,3 +348,3 @@
348 348
      check(G.target(a) == n &&
349
            G.id(G.source(a)) == G.id(n) ^ (1 << G.dimension(a)),
349
            G.id(G.source(a)) == (G.id(n) ^ (1 << G.dimension(a))),
350 350
            "Wrong arc or wrong dimension");
... ...
@@ -354,3 +354,3 @@
354 354
  checkGraphConArcList(G, (1 << dim) * dim);
355
  checkGraphConEdgeList(G, dim * (1 << dim-1));
355
  checkGraphConEdgeList(G, dim * (1 << (dim-1)));
356 356

	
0 comments (0 inline)