I think that I have a fix in place for this defect. Basically I added a call to CastToLHSType after the two CommaExpression calls in the code block that handles ?: expressions. If the lhs type is defined and not equal to the statement type of the last CommaExpression then the value in the register used last is moved into the register for the lhs type (signed, unsigned, or float).
With this change the ASM code without optimizations looks like this:
Code: Select all
set __D0main, 441
mov __main_7qG2_ui_7qG2_000, __D0main
set __D0main, 64
mov __main_7qG2_l_7qG2_000, __D0main
mov __D0main, __main_7qG2_l_7qG2_000
mov __signed_stack_001main, __D0main
mov __DU0main, __main_7qG2_ui_7qG2_000
cmp 0, __D0main, __signed_stack_001main, __DU0main
brtst 4, __ASM_Label_610, __D0main
mov __D0main, __main_7qG2_l_7qG2_000
mov __DU0main, __D0main ; this line of code is generated by CastToLHSType
jmp __ASM_Label_611
__ASM_Label_610:
mov __DU0main, __main_7qG2_ui_7qG2_000
__ASM_Label_611:
mov __main_7qG2_len_7qG2_000, __DU0main
At optimization level 3 it looks like this:
Code: Select all
set __main_7qG2_ui_7qG2_000, 441
set __main_7qG2_l_7qG2_000, 64
mov __DU0main, __main_7qG2_ui_7qG2_000
cmp 0, __D0main, __constVal64, __DU0main
brtst 4, __ASM_Label_610, __D0main
mov __DU0main, __main_7qG2_l_7qG2_000 ; extra mov is optimized out
jmp __ASM_Label_611
__ASM_Label_610:
mov __DU0main, __main_7qG2_ui_7qG2_000
__ASM_Label_611:
mov __main_7qG2_len_7qG2_000, __DU0main
John Hansen