Tool News
 
 
 

Tool News

Products Info
Downloads
Tools FAQs
RENESAS TOOL NEWS on March 1, 2004: RSO-M3T-NC30WA_2-040301D

A Note on Using C Compiler
M3T-NC30WA
--On Using Standard Library Function "strcpy"--

Please take note of the following problem in using C compiler (with an assembler and integrated development environment) M3T-NC30WA for the M16C/60, M16C/30, M16C/Tiny, M16C/20, M16C/10, and R8C/Tiny series MCUs:
  • On using standard library function "strcpy"


  1. Versions Concerned
    M3T-NC30WA V.5.10 Release 1 and V.5.20 Release 1


  2. Description
    Using standard library function "strcpy" may cause System Error to arise.


  3. Conditions
    This problem occurs if the following four conditions are satisfied:
    (1) Optimizing options -OS and -O5 are both selected.
    (2) Standard library function "strcpy" is used.
    (3) The first argument of the strcpy function is an expression that contains a pointer-type external variable.
    (4) The second argument of the function is a string literal.


  4. Examples
    Example 1:
    --------------------------------------------------------
    #include <string.h>
    struct SS {
            int     i;
            char c[20];
    };
    struct SS *ps;
    void func(void)
    {
            strcpy(ps->c,"abcdefghijkl");
    }
    --------------------------------------------------------
    
    Example 2:
    --------------------------------------------------------
    char *p;
    void func(void)
    {
            strcpy(p+2,"abcdefghijkl");
    }
    --------------------------------------------------------

  5. Workaround
    This problem can be circumvented in either of the following ways:
    (1) Replace -O5 with any of those, -O1, O2, O3, and O4.
    (2) Use a dummy asm function as follows:
    (a) Define a temporary pointer variable.
    (b) Assign the string literal to the pointer variable in (a).
    (c) Place a dummy asm function immediately after the assignment in (b).
    (d) Pass the temporary pointer variable in (a) to the strcpy function as its second argument.
    Example:
    --------------------------------------------------------
    char *p;
    void func(void)
    {
            const char *tmp;
            tmp = "abcdefghijkl";
             asm();                 /* Dummy asm function */
            strcpy(p+2,tmp);
    }
    --------------------------------------------------------

  6. Schedule of Fixing the Problem
    We plan to fix this problem in our next release of the product.





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