http://dstress.kuehne.cn/run/s/scope_16_A.d
# void main(){
# scope x = 1.2;
# static assert(is(typeof(x) == double));
#
# x++;
# if(x != 2.2){
# assert(0);
# }
# }
fails only if compiled with "-O"
Comment #1 by bugzilla — 2007-02-02T03:31:29Z
The problem here is that 2.2 is not representable exactly. Constant folding happens in different ways depending on if the optimizer is run or not, resulting in slightly different answers due to roundoff error. Generally speaking, an algorithm that depends on this is always going to have trouble.
To make the example work, use a constant that is exactly representable, like 1.25 and 2.25.
Not a compiler bug.