Skip to content

structs of structs don't seem to work #2036

@etheory

Description

@etheory

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

It'd be great for someone else to confirm they can reproduce this behavior, thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions