Technical information

Operating Precautions for CPDW9X/NT-CDR-V85X, Y-GHS-MULTI-V800
TM
Customer Notification r20tu0003ed1812 109
No. a111
Invalid bitfield handling in optimized If/else clause
Version Information
V5.1.7D, V2012.x, V2013.1.x
Details:
The broken optimization combines assignments to bitfields so that a single load-modify-store
sequence can perform multiple assignments. The issue involves an incorrect interpretation of
control flow.
Example:
extern int printf(const char *, ...);
struct {
unsigned int b1:1;
unsigned int b2:1;
unsigned int b3:1;
unsigned int b4:1;
unsigned int b5:1;
} s = { 0 };
unsigned char flag=0, count=0 ;
void func(void) {
if (flag == 3) {
s.b4 = 0;
if (count == 1)
flag = 2;
} else
s.b1 = 0;
s.b5 = 1;
}
int main( void) {
func();
if (s.b5 != 1)
printf("%s: b5 is false\n", __FILE__);
return 0;
}
Command Line
ccv850 -cpu=v850e2 -G Ospace test.c
Workaround
For V6.1.4/2012.5.5, please use latest patch
Y-GHS-MULTI-V800-FULL-V614_2012.5.5-PATCH01
For V6.1.4/2013.1.5, please use latest patch
Y-GHS-MULTI-V800-FULL-V614_2013.1.5-PATCH02
In case of V5.x.x:
The optimization limitation can be workaround by using special compiler option -Z3245 or -Z990
In general, the limitation can be removed, if the variable is implemented/declared with ‘volatile’
attribute.