-
Bug
-
Resolution: Fixed
-
Medium
-
Code Generation Tools
-
CODEGEN-7098
-
-
-
default
-
Avoid mixing int and wider-than-int types in += and -= expressions. When accumulating into a wider-than-int variable, use wider-than-int operands.
-
The attached test case contains this source line ...
l += a; l -= b;
Variable l is long. Variables a and b are short.
Build it ...
cl430 -o -s try1.c
The resulting assembly is incorrect ...
;** 6 ----------------------- l += a-b; .dwpsn file "try1.c",line 6,column 5,is_stmt,isa 0 MOV.W &a+0,r15 ; [] |6| SUB.W &b+0,r15 ; [] |6| ADD.W r15,&l+0 ; [] |6| ADDC.W #0,&l+2 ; [] |6|
Both a and b should be converted to long, then the expression computed in long. For some reason, that does not occur.