Array of struct containing an array fails #234

sambler opened this Issue Feb 21, 2013 · 4 comments


None yet

3 participants


Section 5.9 of osl-languagespec states:

It is permitted to have a structure field that is an array, as well as to have an array of struc-
tures. But it is not permitted for one structure to have a field that is another structure. For

struct A {
color a;
float b[4]; // struct may contain an array

A d[5]; // Array of structures
color e = d[0].a; // Field of one element of array of struct
d[2].b[4] = 0.25; // Element of a field of a struct in an array

While the last example is an error as the index for b should be < 4,
the array of structs line fails with:-
error: Nested structs with >1 levels of arrays are not allowed: A

I would vote that the compiler is fixed to match this spec rather than just adjusting the spec.


Hey, I'm just starting to play with OSL, and ran into this. Is it likely to change any time soon, or should I be designing around the current behaviour?


I brought that up a year ago so I would say design around it for now. Maybe you could convince @lgritz that this needs to be addressed, or provide a fix yourself.

Sony Pictures Imageworks member

Sorry, this has languished for a while. It's just the right combination of "hard to fix" and "very few people complain." If there's a way to easily design around the problem, I would recommend doing so. If you have a compelling use for this that has no easy workaround, let me know and I can try to find time to take another look.


OK, I'm starting to look at porting a rather complicated shading library to OSL - I should probably hack up an initial working version, and then I'll have a better idea of whether this is going to get in the way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment