 |
|
 |
MESC TOOL NEWS:
MESCT-NC77WA-001116D
Please take note of the following problem in using C compiler NC77WA
for the 77xx series of microcomputers:
- On codes created when bit fields are used both in "if" and "else if" statements in an "if - else if" construct
- Versions Concerned
NC77WA V.5.20 Release 1 -- V.5.20 Release 3
- Problem
When bit fields are used both in "if" and "else if" statements in an "if - else if" construct, codes may be created
which make opposite decisions as to whether the results of evaluating expressions are TRUE or not.
- 2.1 Conditions
- This problem occurs if the following three conditions are satisfied:
- (1) Optimizing option -OR is used.
- (2) Bit fields are used in "if" and "else if" statements in an "if - else if" construct.
- *Note that, however, this problem does not occur when an "if else" construct only (not an "else if" construct) or
switch statements are used.
- (3) In the "if - else if" construct exist just the same program statements executed after evaluating their condition expressions.
- 2.2 Example
-------------------------------------------------------------
if( bitf.bit0 == 1 ){ // Here is created an incorrect code.
i = 0;
} else if( bitf.bit2 == 1 ){
i = 0;
func();
} else if( bitf.bit3 == 1 ){ // Here is created an incorrect code.
i = 0;
}
-------------------------------------------------------------
- Workaround
This problem will be circumvented in either of the following ways:
- (1) When using an optimizing option, select either -O or -OS; not -OR.
- (2) If exactly the same program statements exist in an "if - else if" construct, join their condition expressions using
the logical OR operator (||).
-------------------------------------------------------------
if( (bitf.bit0 == 1) || (bitf.bit3 == 1) ){
i = 0;
} else if( bitf.bit2 == 1 ){
i = 0;
func();
}
-------------------------------------------------------------
- Schedule of Fixing Problem
We plan to fix this problem in our next release.
|
 |