 |
|
 |
MESC TOOL NEWS:
MESCT-CC32R-981001D
Please take note of the following problem in using C compiler cc32R included in cross tool kit CC32R for the M32R family of microcomputers.
Versions Concerned
All the versions of cc32R (see below) are affected. The version number of your product can be examined by giving cc32R the starting option "-V".
- CC32R V.1.00 Release 1
- CC32R V.1.00 Release 2
- CC32R V.1.00 Release 3
Problem: Local Arrays Referenced Incorrectly
- Description
If all of the following four conditions are satisfied, local arrays are referenced incorrectly.
- Conditions
- An option or options including optimization level 4 (-O4, -O5, -O6, -O7, -O, -Otime only, and -Ospace only) are given at compilation.
Note: The options listed above are all including optimization level 4.
- An array defined as a local variable exists in statements.
- A function call exists in statements, and the address of the local array in condition 2 is passed to the argument of the function.
- After the function call in condition 3, the local array in condition 2 is referenced more than once.
- Example
----------------------------------------------------------------------
extern void foo2( int * );
extern int x;
extern int y;
void foo( void )
{
int mx[1]; /* condition (2) */
foo2( &mx[0] ); /* condition (3) */
x = mx[0]; /* condition (4) */
y = mx[0]; /* condition (4) */
}
----------------------------------------------------------------------
- Workaround
Circumvent this problem by using any one of the following four ways:
- Not to give any option including optimization level 4 at compilation
- To declare the array in condition 2 above to be volatile
--------------------------------------------------------------------
extern void foo2( volatile int * ); /* declared to be volatile */
extern int x;
extern int y;
void foo( void )
{
volatile int mx[1]; /* declared to be volatile */
foo2( &mx[0] );
x = mx[0];
y = mx[0];
}
--------------------------------------------------------------------
- To define the array in condition 2 above as a global variable.
--------------------------------------------------------------------
extern void foo2( int * );
extern int x;
extern int y;
int mx[1]; /* defined as a global variable */
void foo( void )
{
foo2( &mx[0] );
x = mx[0];
y = mx[0];
}
--------------------------------------------------------------------
- To provide a pointer variable to reference local arrays
--------------------------------------------------------------------
extern void foo2( int * );
extern int x;
extern int y;
void foo( void )
{
int mx[1];
int *mp = mx; /* provides a pointer variable */
foo2( mp ); /* uses the pointer variable */
x = *mp; /* uses the pointer variable */
y = *mp; /* uses the pointer variable */
}
--------------------------------------------------------------------
|
 |