https://issues.dlang.org/show_bug.cgi?id=16189
Seb <greensunn...@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |greensunn...@gmail.com --- Comment #5 from Seb <greensunn...@gmail.com> --- See also the discussion in the forum: https://forum.dlang.org/post/jguphfhffgtdtfitt...@forum.dlang.org My summary: The optimizer seems to be confused and wrongly precomputes a. Note that if you remove e.g. "if (b) goto loop;", a will be correctly statically set in the printf too: --- mov RSI,0FFFFFFFFh ; look ma - a is now -1 lea RDI,FLAT:.rodata[00h][RIP] xor EAX,EAX ; set eax to 0 call printf@PLT32 --- For comparison the assembly of -O. Here with printf and a different value to be compared with a because it's easier to read: --- main: push RBP mov RBP,RSP sub RSP,010h lea RAX,-010h[RBP] xor ECX,ECX mov [RAX],RCX mov 8[RAX],CL lea RSI,-010h[RBP] lea RDI,-010h[RBP] movsd movsb mov RSI,01C71C71C71C71C70h ; 2 function argument (value of a) lea RDI,FLAT:.rodata[00h][RIP] ; "%d" (1st function argument) xor EAX,EAX ; set eax to 0 call printf@PLT32 ; printf("%d", a) mov EDX,0Ch lea RSI,_TMP0@PC32[RIP] ; load function arguments (in reverse order) lea RDI,_TMP0@PC32[RIP] call __assert@PLT32 ; values load, let's call assert add [RAX],AL .text.main ends end ---- --