Champs,
Our customer has complained that his subroutine in if statement, sub_a(), is called twice. The device is MSP430F5419A.
if(sub_a(1)) {
c = true;
}
I’ve made the attached test code and confirmed his trouble. In the test code, called counters, cntA and cntB, show 2.
bool sub_a(int a)
{
cntA++;
return a>0 ? true : false;
}
But with inserting two NOP, the trouble isn’t caused, cntA shows 1.
if(sub_a(1))
{
__no_operation();
c = true;
__no_operation();
}
I’ve confirmed with CCSv5 and CCSv6, default optimization. The device is F5438A.
CCS Version: 5.5.0.00077, TIv4.2.7(eabi)
CCS Version: 6.1.0.00104, TIv4.4.4(eabi)
Let us know how to avoid this trouble, please.
Regards,
Kazuo Yamauchi