https://issues.dlang.org/show_bug.cgi?id=16268

Lodovico Giaretta <[email protected]> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |[email protected]

--- Comment #1 from Lodovico Giaretta <[email protected]> ---
Looking at the generated assembly, it looks like, as a check x >= 0 is
performed before entering the loop, the compiler establishes that overflow will
not happen while condition i <= x holds (with x not negative).
Of course this is false for the edge case of x = typeof(x).max.

00  push   rbp
01  mov    rbp,rsp
04  push   rbx
05  push   r12
07  mov    r12,rdi
0a  xor    ebx,ebx     ; i = 0
0c  test   r12b,r12b
0f  js     21          ; if x < 0 skip for loop
11  movsx  edi,bl
15  call   <writeln>   ; call writeln
1a  inc    bl          ; i++
1c  cmp    bl,r12b
1f  jle    11          ; if i <= x continue for loop
21  pop    r12
23  pop    rbx
24  pop    rbp
25  ret

--

Reply via email to