structs of structs don't seem to work
Describe the bug
Adding a struct to a struct seems to result in undefined initialization behavior.
OSL version and dependencies
- OSL branch/version: 1.13.12.0.2
- OS: Rocky Linux release 9.4
- C++ compiler: clang-15.0.7.3
- LLVM version: llvm-15.0.7.1
- OIIO version: OpenImageIO-2.4.13.0.4
- Qt version: Qt-5.15.3.8
To Reproduce
Steps to reproduce the behavior:
Given the following structs:
struct StructA
{
float cellRand;
point minDist;
point closest;
point secondClosest;
float edgeDist;
};
struct StructB
{
StructA result;
int level;
float scale;
};
and given a shading function with signature:
StructA somefunction();
If you try and initialize using:
StructB value = StructB(somefunction(), 0, 1.0);
all the attributes are correctly set in the various structs, but if, instead, you do:
StructA temp = somefunction();
StructB value = StructB(temp, 0, 1.0);
then value is incorrect, and the result member is filled with zeroes.
Evidence
- I was trying to assemble a full test example using osltoy, but was blocked by: https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/issues/2035
It'd be great for someone else to confirm they can reproduce this behavior, thanks!
@ld-kerley has suggested to use list initalization as a workaround in the short term. I'll give that a go.
@ld-kerley I tried your suggestion but it didn't work. List initializing still results in empty structures for me.