 |
|
 |
MAEC TOOL NEWS:
MAECT-M3T-CC32R-020401D
A Note on Cross-Tool Kit M3T-CC32R V.3.10 Release 1
|
Please take note of the following problem in using cross-tool kit M3T-CC32R V.3.10 Release 1 for the M32R family MCUs.
- On compiling C-language programs containing switch statements in which the difference between the maximum and minimum values of case labels is too large.
- Description
In a switch statement, compilation may not successfully be performed if the difference between the maximum and minimum values of case labels is too large.
- 1.1 Conditions
- This problem may occur if the following two conditions are satisfied:
- (1) In a switch statement exist two or more case labels, and the difference between the maximum and minimum values is greater than 0x1fffffff.
- (2) The controlling expression of the switch statement in (1) is either of the following:
- (a) A signed variable
- (b) An unsigned variable with all the case values falling within either of the following ranges:
- (i) 0x00000000 to 0x7fffffff
- (ii) 0x80000000 to 0xffffffff
- 1.2 Examples
- A: Source file "sample1.c" in which the controlling expression of the switch statement is a signed variable
[Condition (2)-(a) satisfied]
--------------------------------------------------------------------
int ans;
void func(signed long s)
{
switch (s) { /* Condition (2)-(a) */
case -0x50000000: /* Minimum value; Condition (1) */
case -0x30000000: /* Maximum value; Condition (1) */
ans += 1;
break;
case -0x40000003:
ans += 2;
break;
case -0x40000000:
ans += 3;
break;
}
}
--------------------------------------------------------------------
B: Source file "sample2.c" in which the controlling expression of the switch statement is an unsigned variable
[Condition (2)-(b) satisfied]
--------------------------------------------------------------------
int ans;
void func(unsigned long u)
{
switch (u) { /* Condition (2)-(b) */
case 0x10000000: /* Minimum value; Conditions (1)
and (2)-(b)-(i) */
case 0x20000000:
case 0x30000000: /* Maximum value; Conditions (1)
and (2)-(b)-(i) */
ans += 1;
break;
}
}
--------------------------------------------------------------------
[Examples of Executing Commands in CC32R (Here % denotes a prompt.)]
--------------------------------------------------------------------
% cc32R -S sample1.c
% cc32R -S sample2.c
--------------------------------------------------------------------
- Workaround
- 2.1 Case A where the controlling expression of the switch statement is a signed variable [Condition (2)-(a) satisfied]
- Make the difference between the maximum and minimum values equal to or less than 0x1fffffff.
[Example A: Source file "sample1.c"]
--------------------------------------------------------------------
int ans;
void func(signed long s)
{
switch (s/0x10000000) {
case -0x5:
case -0x3:
ans += 1;
break;
case -0x4:
if (s == -0x40000003) {
ans += 2;
} else {
ans += 3;
}
break;
}
}
--------------------------------------------------------------------
- In this example, the variable of the controlling expression of the switch statement is divided by 0x10000000 to make the difference between the maximum and minimum values of case labels equal to or less than 0x1fffffff.
However, case values -0x40000000 and -0x40000003 are made the same value of -0x4 by division, so an additional processing is needed in such a case.
- 2.2 Case B where the controlling expression of the switch statement is an unsigned variable [Condition (2)-(b) satisfied]
- Add a dummy case label whose value is outside the range of (2)-(b)-(i) or -(ii), as shown below.
0x80000000 or greater in the case of (2)_(b)_(i), or
0x7fffffff or less in the case of (2)_(b)_(ii)
[Example B: Source file "sample2.c"]
--------------------------------------------------------------------
int ans;
void func(unsigned long u)
{
switch (u) {
case 0x10000000:
case 0x20000000:
case 0x30000000:
ans += 1;
break;
case 0xffffffff: /* A dummy label added so that
Condition (2)-(b)-(i) might not be met */
break;
}
}
--------------------------------------------------------------------
- Schedule of Fixing the Problem
We plan to fix this problem in our next release.
|
 |