OK, I just tested this a bit with GCC and it seems as soon as you turn on -O1 there is no way of preventing constant folding. `volatile` does the trick though.