Tool News
 
 
 

Tool News

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

CC32R
Precaution

Please take note of the following problem in using cross-tool kit CC32R for the M32R family of MCUs:
  • On referencing a global variable three or more times successively



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

  2. Problem
    When a global variable is read three or more times successively in a C-language program, a code that reads out the variable may be generated in incorrect timing (before calling a function, for example) if the program is compiled with size-oriented optimize option -Ospace selected.

    2.1 Conditions
    This problem occurs if the following three conditions are satisfied:
    (1) -Ospace is used as an option for compilation.
    (2) A global variable is read out three or more times successively.
    (3) The value of the global variable in (2) is altered in either of the following ways before it is read out:
    (a) Calling a function that alters the global variable
    (b) Using a pointer that points to the global variable


    2.2 Examples
    Example 1:
         -------------------------------------------------------------------
         int glb_data = 2;  Example 1:
    
         void
         func(void)
         {
            glb_data = 4;
         }
    
         int
         foo(void)
         {
            int     retcode = 0;
    
           /* Condition (3)-(a): Calling a function that alters glb_data */
            func();
    
           /* Condition (2): Referencing the global variable successively */
            if(glb_data > 0 && glb_data <= 8 && glb_data != 4) {
                    retcode = 1 ;
            }
    
            return(retcode);
         }
         -------------------------------------------------------------------
    
    In Example 1, an if statement will be tested by referencing the value of glb_data before calling the "func()" function

    Example 2:
         -------------------------------------------------------------------
         int glb_data = 2;        /* A global variable */
         int *ptr = &glb_data;    /* A pointer pointing to glb_data */
    
         int
         foo(void)
         {
            int     retcode = 0;
    
           /* Condition (3)-(b): Altering the value of glb_data by the pointer */
            *ptr = 8;
    
           /* Condition (2): Referencing the global variable successively */
            if(glb_data > 0 && glb_data <= 8 && glb_data != 4) {
                    retcode = 1 ;
            }
    
            return(retcode);
         }
         -------------------------------------------------------------------
    
    In Example 2, an if statement will be tested by referencing the value of glb_data before assigning the specified value to *ptr.


  3. Workaround
    This problem will be circumvented either of the following ways:
    (1) Don't use -Ospace as an option for compilation.
    (2) Reference the global variable using a temporary pointer.

    Circumvention of Example 1:
        -------------------------------------------------------------------
         static int glb_data = 2;  /* A global variable */
    
         void
         func(void)
         {
            glb_data = 4;
         }
    
         int
         foo(void)
         {
            int     retcode = 0;
            int     *tmp_ptr = &glb_data;   /* A temporary pointer pointing 
                                                             to glb_data */
    
           /* Condition (3)-(a): Calling a function that alters glb_data */
            func();
    
           /* Referencing glb_data successively using the temporary pointer */
            if(*tmp_ptr > 0 && *tmp_ptr <= 8 && *tmp_ptr != 4) {
                    retcode = 1 ;
            }
    
            return(retcode);
         }
         -------------------------------------------------------------------
    

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






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