aboutsummaryrefslogtreecommitdiff
path: root/tests/core/test_stack_byval.in
blob: d7007d0a66e310dd94ceb24313d9dc7a1794b1d4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
// We should also not blow up the stack with byval arguments
#include <stdio.h>
struct vec {
  int x, y, z;
  vec(int x_, int y_, int z_) : x(x_), y(y_), z(z_) {}
  static vec add(vec a, vec b) { return vec(a.x + b.x, a.y + b.y, a.z + b.z); }
};
int main() {
  int total = 0;
  for (int i = 0; i < 1000; i++) {
    for (int j = 0; j < 1000; j++) {
      vec c(i + i % 10, j * 2, i % 255);
      vec d(j * 2, j % 255, i % 120);
      vec f = vec::add(c, d);
      total += (f.x + f.y + f.z) % 100;
      total %= 10240;
    }
  }
  printf("sum:%d*\n", total);
  return 0;
}