|
|
|
|
|
by comex
4398 days ago
|
|
C: #include <stdio.h>
#include <stdbool.h>
#include <stdlib.h>
int nums[5] = {1, 0, 1, 0, 1};
static int cur;
int main(int argc, char **argv) {
for(int i = 1; nums[i] != 5 && i < 10; i++) {
cur = i;
if(i/4 == 1) {
printf("2 + 2 <= %d = %s\n", cur, 2 + 2 <= i ? "true" : "false");
printf("2 + 2 == %d = %s\n", cur, 2 + 2 == i ? "true" : "false");
printf("\n");
}
}
}
No strange array writes! No indirect writes at all!It's finicky and I believe depends on register allocation, but when I compile it using whatever version of gcc-mp-4.9 I have installed from MacPorts at -O3, it outputs, among other things: 2 + 2 == 5 = true
(For all they say about evil optimizing compilers, it was really hard to make this work.) |
|