Bug 813 – regression: optimizer & scope

Status
RESOLVED
Resolution
INVALID
Severity
normal
Priority
P3
Component
dmd
Product
D
Version
D1 (retired)
Platform
All
OS
All
Creation time
2007-01-07T10:15:00Z
Last change time
2014-02-15T13:12:56Z
Assigned to
bugzilla
Creator
thomas-dloop

Comments

Comment #0 by thomas-dloop — 2007-01-07T10:15:56Z
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.