Tool News
 
 
 

Tool News

Products Info
Downloads
Tools FAQs
MESC TOOL NEWS: MESCT-CC32R-000601D

CC32R
Precaution

Please take note of the following problem in using cross-tool kit CC32R for the M32R family of microcomputers:


  1. Versions Concerned
    CC32R V.1.00 Release 1 -- V.2.10 Release 1

  2. Problem
    When the result of the above mentioned assignment is used for operations between 4-byte variables of type int, the results of these operations may be incorrect.

    2.1 Conditions
    This problem occurs if the following four conditions are satisfied:
    (1) An optimize option whose function includes that of option -O4 is chosen.
    (Any option of -O, -Ospace, and -Otime, each of which incorporates -O4's optimize function, is chosen without other optimize options, or only -O4, or any option of -O5 through -O7, also incorporating -O4's optimize function, is chosen.) For details, refer to "Command Options" of the CC32R manual.
    (2) An assignment statement "variable A = right expression B" exists, where the following conditions (a)--(c) are satisfied:
    (a) As a result of optimization (1), variables A and right expression B are both assigned to registers.
    [Objects stored in registers]
    * auto variables
    * return values of functions (* always stored in registers)
    * arguments of functions (* stored only when the -RBPP option used)
    (b) Variables A and right expression B are both 1 or 2 bytes long.
    (c) Variables A and right expression B are different from each other in sign attribute.
    (3) In (2) above, the value of right expression right expression B is beyond the range of the valid values in the type of variable A.
    (4) The value of A after the assignment in (2) is used for operations between 4-byte variables of type int.

    2.2 Examples
         [Example 1]
          ---------------------------------------------------------------------
          extern  int             get_data(void);
          extern  short           get_work(void);
          int     flag;
         
          int
          func(void)
          {
               int             answer;
               unsigned short  work;
    
               answer = get_data(); /* Condition (2)-(a) */
               work   = get_work(); /* Conditions (2)-(a) and (2)-(c): 
                                                    short -> unsigned short */
              if (flag) {
                    answer += work; short -> unsigned short */
    
               }
               return answer;
          }
          ---------------------------------------------------------------------
    
         [Example 2]
          ---------------------------------------------------------------------
          extern  unsigned long   get_data(void);
          extern  unsigned short  get_work(void);
          int     flag;
         
          unsigned long
          func(void)
          {
               unsigned long   answer;
               short           work;
    
               answer = get_data();
               work   = get_work(); /* Conditions (2)-(b) and (2)-(c): 
                                                    unsigned short -> short */
               if (flag) {
                   answer += work;  /* Condition (4): of type unsinged long */
               }
               return answer;
          }
          ---------------------------------------------------------------------
    
    In the assignment statement "work = get_work( )" in Examples 1 and 2, if the return value of get_work( ) is beyond the range of 0x0000--0x7fff (condition (3) above), the value of "answer" obtained by the expression "answer += work" will become incorrect.


  3. Workaround
    This problem will be circumvented by any of the following ways:
    (1) In the assignment statement "variable A = right expression B", change the type of right expression right expression Bto that of A, or change it to the type longer than that of A.
    (2) Otherwise, change the program such a way that the values permitted to variable A are within the range of the valid values in the type of right expression B. (In Examples 1 and 2, change the program so that the get_work( ) function returns a value within the range of 0x0000--0x7fff.)
    (3) Use no optimize option whose function includes that of option -O4 to sidestep condition (1) .

  4. Schedule of Fixing Problem
    We plan to fix this problem in our next release.

  5. Note
    In the ANSI C standard, assigning a value beyond the range of the valid values of a variable, as described in condition (3) above, is dealt with as implementation-dependent. Therefore, if you switch from CC32R to another ANSI C-conforming compiler, you might see a different result from that of CC32R in such an implementation-dependent operation.




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