cgen icon indicating copy to clipboard operation
cgen copied to clipboard

Wrong result for nested type

Open JanisEst opened this issue 6 years ago • 4 comments

Both

Pointer(ArrayOf(Pointer(POD(np.float32, "xxx")), 2)),
Pointer(Pointer(ArrayOf(POD(np.float32, "yyy"), 2))),

result in

float **xxx[2];
float **yyy[2];

The expected result is

float *(*xxx)[2];
float (**xxx)[2];

JanisEst avatar Jan 26 '19 15:01 JanisEst

Thanks for the report, and sorry about the delay in responding. Could you take a look at #23 , especially since it disagrees with your proposed correct solution (the second one)?

inducer avatar Sep 30 '19 03:09 inducer

I had to revert #23 for the time being as it caused a bit more breakage than anticipated. #25 is the new version.

inducer avatar Oct 09 '19 04:10 inducer

Thank you for both fixes but I'm not sure if it is correct now.

import cgen as c

x = c.Pointer(c.ArrayOf(c.Value("float", "temp"), 2))
print(x) # float *(temp[2]);
x = c.ArrayOf(c.Pointer(c.Value("float", "temp")), 2)
print(x) # float (*temp)[2];

If I understand this library correct the first x should be a pointer to array[2] of float and the second should be an array[2] of pointer to float. The generated code is the opposite.

JanisEst avatar Oct 09 '19 17:10 JanisEst

cc @kaushikcfd

inducer avatar Oct 09 '19 17:10 inducer