 |
|
 |
MESC TOOL NEWS:
MESCT-CC32R_2-000316D
Please take note of the following problems in using cross-tool kit CC32R for the M32R family of microcomputers:
-
Versions Concerned
CC32R V.1.00 Release 1 -- V.2.10 Release 1
-
Problems
When a structure is defined which contains both bit-field members and members of other types,
- (1) if all the members of a structure are given their initial values, the following internal error message appears:
- cg32r: "file name", line number: internal error: illegal IL, size of initializer is larger than name size,
- (2) and if the initial values of several members of a structure are omitted, the initial value of the bit-field member described for the first time and those of the following members may become incorrect.
- 2.1 Conditions (applied to both of problems (1) and (2) above)
- These problems occur if the following five conditions are satisfied:
- (1) A structure contains both bit-field members and members of other types.
- (2) Immediately before a bit-field member is described a member of other type.
- (3) The bit-field member in condition (2) above is placed on a 1- or 2-byte boundary.
- (4) The bit-field member in condition (2) above is initialized as well as defined.
- (5) The structure contains a member larger in size than the member of other type described in condition (2) above.
- 2.2 Examples of problem (1)
-
[Example 1]
--------------------------------------------------------------------
struct tag {
char a ; /* Condition (2) */
char b : 3; /* Condition (3): Placed on a 1-byte boundary
because the preceding member is of
type char */
short c ; /* Condition (5) */
} foo = { 1, 2, 3 }; /* Condition (4) */
--------------------------------------------------------------------
[Example 2]
--------------------------------------------------------------------
struct tag {
short a ; /* Condition (2) */
char b : 3; /* Condition (3): Placed on a 2-byte boundary
because the preceding member is of
type short */
long c ; /* Condition (5) */
} foo = { 1, 2, 3 }; /* Condition (4) */
--------------------------------------------------------------------
[Example 3]
--------------------------------------------------------------------
struct tag {
struct {
short aa : 2;
} a; /* Condition (2): "a" is a structure
consuming 2 bytes */
char b : 3; /* Condition (3): Placed on a 2-byte
boundary because the preceding member
consumes 2 bytes */
struct {
long cc : 2;
} c; /* Condition (5): "c" is a structure
consuming 4 bytes */
} foo = {{1}, 2, {3}}; /* Condition (4) */
--------------------------------------------------------------------
- 2.3 Examples of problem (2)
- If the initial values of several members of a structure are omitted in the ways shown below in Examples 1 through 3 of Problem (1), the initial value of member "b" becomes incorrect though no internal error arises:
The initializing expression is modified to foo = { 1, 2 } in Examples 1 and 2.
The initializing expression is modified to foo = { {1}, 2 } in Examples 3.
-
Workaround
These problems will be circumvented by any of the following three ways (note that, however, the first way can not be applied to Example 3):
- (1) Change the member placed immediately before the bit-field member that satisfies condition (2) to a bit-field member (the circumvention of condition (2)).
-
[Example 1 after Circumvention]
--------------------------------------------------------------------
struct tag {
char a ; 8; /* Changed to a bit-field member with the
original bit length maintained */
char b : 3;
short c;
} foo = { 1, 2, 3 };
--------------------------------------------------------------------
- (2) Add a line defining a temporary member which is placed on a 4-byte boundary immediately before the bit-field member that satisfies condition (2)
(the circumvention of condition (3)).
-
[Example 2 after Circumvention]
--------------------------------------------------------------------
struct tag {
short a ;
long : 0; /* Added to a member which is placed on
a 4-byte boundary */
char b : 3; /* Condition (3) circumvented by adjusting
the boundary */
long c ;
} foo = { 1, 2, 3 };
--------------------------------------------------------------------
- (3) Change the bit-field member that satisfies condition (2) to a structure (the circumvention of condition (2)).
- Note: In accordance with the change of the type of a member, the initializing expression of the member and programs referencing it must be modified.
[Example 3 after Circumvention]
--------------------------------------------------------------------
struct tag {
struct {
short aa : 2;
} a;
struct { /* Changed to a structure */
char b : 3; /* Note: Programs referencing "b" must
be changed to "bb.b" */
} bb;
struct {
long cc : 2;
} c;
} foo = {{1}, {2}, {3}}; /* Initializing expression modified
according to the above change */
--------------------------------------------------------------------
-
Schedule of Fixing Problems
We plan to fix these problems in our next release.
|
 |