Tool News
 
 
 

Tool News

Products Info
Downloads
Tools FAQs
MAEC TOOL NEWS: MAECT-M3T-NC30WA-020801D

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 V.5.00 Release 1 for the M16C/60, M16C/30, M16C/20, and M16C/10 series MCUs:
  • On two successive if constructs with the same conditional expression
  • On incorrectly deleting codes in selection statements such as if statements by optimization


  1. Problem on Two Successive if Constructs with the Same Conditional Expression
    1.1 Description
    When two if constructs with the same conditional expression are described in succession, "System Error" may arise or incorrect codes be generated.

    1.2 Conditions
    This problem occurs if the following seven conditions are satisfied:
    (1) Any one or more of optimizing options -O, -O[3-5], -OR, and -OS are used, and -ONBSD (-Ono_break_source_debug) is not selected.
    (2) Two if constructs with the same conditional expression are described in succession, and between them is described nothing. The first if construct is called if construct A and the second is if construct B, hereafter.
    (3) The variable used in the conditional expression in (2) is an auto variable or an argument to a function.
    (4) An if statement exists at the end of the program statement in if construct A.
    (5) An if statement exists at the beginning of the program statement in if construct B.
    (6) The variable used at the beginning of the conditional expression of the if statement in (5) is also used in the conditional expression of the if statement in (4).
    (7)The variable in (6) meets all the following conditions:
    It is a global or static variable.
    It is not declared using the volatile qualifier.
    Its type is any one of the following:
         _Bool,
         signed char,   unsigned char,
         signed int,    unsigned int,
         signed short,  unsigned short,
         signed long,   and unsigned long
    1.3 Example
    -----------------------------------------------------------------------
       int             gi1;                 /* Condition (7) */
       int             gi2;
       char            gc;
       void func(void)
       {
           int ac = gc + 2;
      -    if(ac){                          /* Conditions (2) and (3) */
      |            :
      |        if(gi2 == 7 && gi1 == 6){    /* Conditions (4) and (6) */
      A            gi1 = 3;
      |        }
      |    }
      -                                     /* Condition (2) */
    
      -    if(ac){                          /* Conditions (2) and (3) */
      |        if(gi1 == 5 && gi2 == 8){    /* Conditions (5) and (6) */
      |            gi1 = 5;
      B        }
      |            :
      |    }
      - 
       }
    -----------------------------------------------------------------------
    1.4 Workaround
    This problem will be circumvented in either of the following ways:
    (1) Place a dummy asm function between two if constructs in Condition (2) above.
    (2) Compile the program using optimizing option -ONBSD (-Ono_break_source_debug).
    [Example]
    -----------------------------------------------------------------------
       int             gi1;
       int             gi2;
       char            gc;
       void func(void)
       {
           int ac = gc + 2;
      -    if(ac){
      |            :
      |        if(gi2 == 7 && gi1 == 6){
      A            gi1 = 3;
      |        }
      |    }
      -
           asm();                          /* A dummy asm function placed */
      -    if(ac){
      |        if(gi1 == 5 && gi2 == 8){
      |            gi1 = 5;
      B        }
      |            :
      |    }
      - 
       }
    -----------------------------------------------------------------------
    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-020801D

  2. Problem on Incorrectly Deleting Codes in Selection Statements Such as if Statements by Optimization
    2.1 Description
    When compiling an if-else construct using optimizing options, codes for the selection statements of the if-else construct may be deleted incorrectly.

    2.2 Conditions
    This problem occurs if the following seven conditions are satisfied:
    (1) Any one or more of optimizing options -O, -O[1-5], -OR, and -OS are used.
    (2)An if-else construct exists.
    (3) After the if-else construct in (2) is described another selection statement (including a switch statement) or an iteration statement (for, while, or do-while), and an auto variable is used in its conditional expression.
    (4) One or more conditional expressions exist in either of the if and the else statement involved in the if-else construct in (2) above.
    (5) The assignment expressions to the same auto variable exist in both of the if and the else statement involved in the if-else construct in (2) above, and the assignment expression(s) in either of the if and the else statement is executed according to the evaluation of the conditional expression(s) in (4).
    (6) The assignment expressions in (5) make the results of evaluation of the conditional expression in (3) be the same value.
    (7) Between the if-else construct in (2) and the selection or iteration statement in (3) exists no statement for referencing the auto variable in (5).

    2.3 Examples
    [Example 1]
    -----------------------------------------------------------------------
       void func(void) {
                   int k;                  /* Condition (5) */
                   k = 0; 
    
             -    if(i == 0){
             |            k = 1;           /* Conditions (5) and (6) */
             |     }else{
             |            if(j == 0){      /* Condition (4) */
            (2)                 k = 1;     /* Conditions (5) and (6) */
             |            }
             |            if(j == 1){      /* Condition (4) */
             |                  k = 1;     /* Conditions (5) and (6) */
             |            }
             -    }
    
                                           /* Condition (7) */
    
             -    if(k == 1)               /* Condition (3) */
             |            gi++;
            (3)            :
             |             :
             -    }
    -----------------------------------------------------------------------
    
    [Example 2]
    -----------------------------------------------------------------------
       void func(void) {
               int k;                       /* Condition (5) */
               k = 0;
         
              -    if(i == 0){
              |            k = 1;           /* Conditions (5) and (6) */
              |    }else{
              |            switch(j){       /* Condition (4) */
              |            case 0:
              |            case 1:
             (2)                 k = 1;     /* Conditions (5) and (6) */
              |                  break;
              |            }
              |            if(j == 1){      /* Condition (4) */
              |                  k = 1;     /* Conditions (5) and (6) */
              |            }
              -    }
    
                                            /* Condition (7) */
    
             -    if(k == 1)  {             /* Condition (3) */
             |            gi++;
            (3)             :
             |              :
             -    }
    -----------------------------------------------------------------------
    In the source files shown in examples 1 and 2, codes generated by compiling the conditional expression in Condition (3) will be deleted.
    The reason is that even if immediate value 1 is not assigned to variable k in the if-else construct in Condition (2), M3T-NC30WA interprets the value of variable k in the conditional expression in Condition (3) as immediate value 1; as a result, codes are incorrectly deleted.

    2.4 Workaround
    Place a dummy asm function immediately before the conditional expression involved in the deletion.
    -----------------------------------------------------------------------
       void func(void) {
           int k;
    
           k = 0;
           if(i == 0){
               k = 1;
           }else{
               if(j == 0){
                   k = 1;
               }
               if(j == 1){
                   k = 1;
               }
           }
    
           asm();                     /* A dummy asm function placed */
    
           if(k == 1)
               gi++;
       }
    -----------------------------------------------------------------------
    2.5 Schedule of Fixing the Problem
    We plan to fix this problem in our next release.




© 2008. Renesas Technology Corp., All rights reserved. Privacy | Legal