https://issues.dlang.org/show_bug.cgi?id=18534
Issue ID: 18534 Summary: Wrong code for ?: operator when compiling with -O Product: D Version: D2 Hardware: x86_64 OS: Linux Status: NEW Severity: normal Priority: P1 Component: dmd Assignee: nob...@puremagic.com Reporter: hst...@quickfur.ath.cx Code: ------- auto foo(int invert) { import std.format : format; return format("%c", invert ? 'A' : 'A'); } void main() { auto s = foo(0); assert(s == "A"); // assertion fails } ------- Compile command: ------- dmd -O -run test.d ------- Inspecting the contents of s reveals that instead of containing the character 'A', it contains 0xFF instead. Compiling without -O fixes the problem. Replacing the conditional with just 'A' also makes the problem go away. Seems like -O generates wrong code for the ?: operator. --