Critical Issue
Description
Array Elements of Structs
C2H accelerators do not correctly copy array elements that are elements of structures.
In , the a
and b
elements
of the structure copy correctly, but the buf
element
does not. After this assignment, struct_a
equals {9,
8, {3, 3, 3, 3}}
.
typedef struct my_struct {
int a;
int b;
int buf[BUF_SIZE];
}MY_STRUCT;
MY_STRUCT struct_a = {1, 2, {3, 3, 3, 3}};
MY_STRUCT struct_b = {9, 8, {7, 7, 7, 7}};
struct_a = struct_b; |
Resolution
Copying Array Elements Explicitly
Copy the array elements explicitly, as shown in .
{
int i=0;
do
{
struct_a.buf[i] = struct_b.buf[i];
i ;
} while (i<LENGTH_OF_BUF_ELEMENT)
} |