Tool News
 
 
 

Tool News

Products Info
Downloads
Tools FAQs
MAEC TOOL NEWS: MAECT-M3T-NC308WA_2-020916D

A Note on C Compilers
M3T-NC308WA V.5.00 Release 1 and
M3T-NC30WA V.5.00 Release 1

Please take note of the following problem in using C compilers (with an assembler and integrated development environment) M3T-NC308WA and M3T-NC30WA:
  • On describing an if or switch statement


  1. Products and Versions Concerned
    M3T-NC308WA V.5.00 Release 1
    for the M32C/80 and M16C/80 series of MCUs
    M3T-NC30WA V.5.00 Release 1
    for the M16C/60, M16C/30, M16C/20, and M16C/10 series of MCUs

  2. Description
    When an auto variable storing a value is updated to another value in the program statement in an if or switch statement, the auto variable may not correctly be assigned to a register.

  3. Conditions
    This problem may occur if the following nine conditions are satisfied:
    (1)Any one or more options are selected out of -O, -O[3-5], -OR, and -OS.
    (2)Option -ONBSD(-Ono_break_source_debug) is not selected.
    (3)An auto variable is assigned to a register.
    (4)An assignment expression "a" assigns a value to the auto variable in (3).
    (5) There exists an if or switch selection statement, and its conditional expression evaluates the value that has been assigned to a register.
    (6)An assignment expression "b" that assigns a value to the auto variable in (3) exists in any of the program statements listed below. These program statements are written in the selection statement in (5)
    *Either of the program statements for the if and else sections in an if-else statement.
    *The program statement for the if section in an if statement.
    *One or more, but not all, program statements for the case and default labels in a switch statement.
    (7)The right term of the assignment expression "b" is the variable evaluated in the conditional expression in (5).
    (8)The auto variable in (3) is never referenced after the conditional expression in (5) until the assignment expression "b" in (6) started.
    (9)The auto variable in (3) is referenced after the selection statement in (5) ended.

  4. Example
    -----------------------------------------------------------
        char gc,gc2;
        void func(void)
        {
    -
    a            char c = 0;          /* Condition (4) */
    -
                switch(gc){           /* Condition (5) */
                case    1:
                case    2:
    -
    b                 c = gc;         /* Conditions (6) and (7) */
    -
                     break;
             default:
                     break;
             }
             if(c != 0){              /* Condition (9) */
                     gc2++;
             }
        }
    -----------------------------------------------------------
  5. Workaround
    This problem will be circumvented in any of the following ways:
    (1) Compile programs after deselecting the -O, -O[3-5], -OR, and -OS options.
    (2) Use option -ONBSD(-Ono_break_source_debug).
    (3) Place a dummy asm function immediately before the if or switch statement.
    [Example]
    -----------------------------------------------------------
       char gc,gc2;
       void func(void)
       {
           char c = 0;
           asm();               /* A dummy asm function placed */
           switch(gc){
           case    1:
           case    2:
                   c = gc;
                   break;
           default:
                   break;
           }
           if(c != 0){
                   gc2++;
           }
       }
    -----------------------------------------------------------
  6. Schedule of Fixing the Problem
    For M3T-NC308WA, we plan to fix this problem in our next release.
    For M3T-NC30WA, the problem has been fixed in its V.5.00 Release 2.




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