Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug with storing arrays in structs #64

Closed
0152la opened this issue Oct 14, 2014 · 0 comments
Closed

Bug with storing arrays in structs #64

0152la opened this issue Oct 14, 2014 · 0 comments

Comments

@0152la
Copy link

0152la commented Oct 14, 2014

Assume the following struct definition:

struct S0 {
uchar a;
ulong b[2][3][1];
}

, followed by this initialization:

struct S0 s {
1UL,
{{{1L},{1L},{1L}},{{1L},{1L},{1L}}},
}.

Finally, we iterate through the struct and add the values to a variable:

ulong c = 0UL;
for (i = 0; i < 2; i++)
for (j = 0; i < 3; j++)
for (k = 0; k < 1; k++)
c += s.b[i][j][k];

Reading the result from the variable returns 0x4 in oclgrind, compared to the expected 0x6 as with other platforms.

The types of the members of the struct did not seem to affect this result, but removing the first element makes the bug go away. Also, lower sizes for the dimensions, as well as less than 3 dimensions, did not exhibit the bug.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants