diff --git a/src/dmd/backend/cod2.d b/src/dmd/backend/cod2.d index 2edd9912b4d8..91512a9c245a 100644 --- a/src/dmd/backend/cod2.d +++ b/src/dmd/backend/cod2.d @@ -4554,8 +4554,7 @@ else cdb.genc2(0x81,(rex << 16) | modregrm(3,5,DI), type_size(e.ET)); // SUB DI,numbytes regm_t retregs = mDI; - if (*pretregs & mMSW && !(config.exe & EX_flat)) - retregs |= mES; + if (*pretregs & mMSW) retregs |= mES; fixresult(cdb,e,retregs,pretregs); } } diff --git a/test/compilable/test22175.d b/test/compilable/test22175.d new file mode 100644 index 000000000000..6f054980a5b0 --- /dev/null +++ b/test/compilable/test22175.d @@ -0,0 +1,19 @@ +// https://issues.dlang.org/show_bug.cgi?id=22175 +struct Struct +{ + short a, b, c, d; + bool e; +} + +Struct foo() +{ + return Struct.init; +} + +void main() +{ + int i = 0; + Struct var = i ? Struct.init : foo; + + Struct test() { return var; } +}