RVBTCC/demo/misc.c
2024-12-07 14:13:34 +08:00

26 lines
493 B
C

int printf(char* format, ...);
void should_be(int expected, int actual) {
if (expected != actual) {
printf("Expected %d, but got %d\n", expected, actual);
} else {
printf("Passed\n");
}
}
int* p = 0;
int f1() {
int a = 1;
return *(a+(a+(a+(a+(a+(a+(a+(a+(a+(a+(p))))))))))); // p[10]
}
int main() {
int a[15];
p = a;
for (int i = 0; i < 15; a[i] = i, ++i);
p -= 5;
should_be(5, f1());
should_be(5, a - p);
should_be(10, 5);
}