 |
|
 |
MAEC TOOL NEWS:
MAECT-M3T-NC30WA-020601D
Notes on C Compiler M3T-NC30WA V.5.00 Release 1
|
Please take note of the following problems in using C compiler (with an assembler and integrated development environment) M3T-NC30WA for the M16C/60, M16C/30, M16C/20, and M16C/10 series MCUs:
- On using variables of type _Bool
- On an if-else construct with if and else statements whose program statements have if-else constructs with the same conditional expression
- Problem on Using Variables of Type _Bool
- 1.1 Description
- Assigning variables of type unsigned char or signed char to those of type _Bool generates an error that displays the message shown below, resulting in the compiler being forcefully terminated.
----------------------------------------------------------------------
This program has performed an illegal operation and will be shut down.
----------------------------------------------------------------------
- 1.2 Conditions
- This problem occurs if codes are described which are associated with operations of assigning or casting variables of type signed char or unsigned char to those of type _Bool.
- 1.3 Example
----------------------------------------------------------------
char gc1,gc2;
_Bool gb;
void func(void)
{
gb = gc1; /* A char-type variable is assigned
to a _Bool-type one */
gb = (_Bool)(gc1 + gc2); /* The result of operation
between char-type variables
is cast to a _Bool-type one */
}
----------------------------------------------------------------
- 1.4 Workaround
- Convert variables of type unsigned char or signed char to those of type _Bool through casting them to those of type other than _Bool.
----------------------------------------------------------------
char gc1,gc2;
_Bool gb;
void func(void)
{
gb = (int)gc1;
gb = (int)(gc1 + gc2);
}
----------------------------------------------------------------
- 1.5 Schedule of Fixing the Problem
- We plan to fix this problem in our next release.
Notes on C Compiler M3T-NC30WA V.5.00 Release 1 MAECT-M3T-NC30WA-020601D
- Problem on an if-else Construct with if and else Statements Whose Program Statements Have if-else Constructs with the Same Conditional Expression
- 2.1 Description
- When an if and an else statement in an if-else construct contain an if-else construct within each of them, and the inner if-else constructs have the same conditional expression in their program statements, incorrect code may be generated at compilation.
- 2.2 Conditions
- This problem occurs if the following six conditions are satisfied:
- (1) Option -OR is selected.
- (2) Option -ONBSD(-Ono_break_source_debug) is not selected.
- (3) An if-else construct exists in the program.
- (4) An if and an else statement in an if-else construct in Condition (3) contain an if-else construct within each of their program statements.
- (5) The if-else constructs in (4) satisfy the following conditions:
- (a) The conditional expressions in both if statements are the same.
- (b) Each program statement of both if statements and of both else statements are only an assignment expression that assigns any immediate value to the same variable.
- (c) The type of variable in (b) above is any of the following:
- signed char
- signed int
- signed short
|
- unsigned char
- unsigned int
- unsigned short
|
- (6) The program statements of the if and else statements in (4) is the same.
- 2.3 Example
----------------------------------------------------------------
int gi;
char gc;
void func(void)
{
if(gc){ /* Condition (3) */
if(gi == 5){ /* Conditions (4) and (5)(a) */
gc = 3; /* Conditions (5)(b) and (5)(c) */
}else{ /* Condition (4) */
gc = 4; /* Conditions (5)(b) and (5)(c) */
}
gi += 2; /* Condition (6) */
}else{ /* Condition (3) */
if(gi == 5){ /* Conditions (4) and (5)(a) */
gc = 5; /* Conditions (5)(b) and (5)(c) */
}else{ /* Condition (4) */
gc = 6; /* Conditions (5)(b) and (5)(c) */
}
gi += 2; /* Condition (6) */
}
}
----------------------------------------------------------------
- 2.4 Workaround
- This problem will be circumvented in either of the following ways:
- (1) Compile the program using option -ONBSD (-Ono_break_source_debug).
- (2) Add a dummy asm function immediately after the if-else construct within the if statement in Condition (4).
[Example of circumvention using the way of (2) above]
----------------------------------------------------------------
int gi;
char gc;
void func(void)
{
if(gc){
if(gi == 5){
gc = 3;
}else{
gc = 4;
}
asm(); /* Dummy asm function added */
gi += 2;
}else{
if(gi == 5){
gc = 5;
}else{
gc = 6;
}
gi += 2;
}
}
----------------------------------------------------------------
- 2.5 Schedule of Fixing the Problem
- We plan to fix this problem in our next release.
|
 |