I hope Core module is the right category for this?
When running the tests the test geo_node_mesh_test_sample_uv_surface sometimes fails. When debugging this I traced it back to the call:
line 167: dst_typed[i] = {};
In the file source/blender/nodes/geometry/nodes/node_geo_sample_uv_surface.cc .
This calls the default constructor of the current type the template is instantiated with. In this specific test it’s a derived class of ColorRGBA .
The class ColorRGBA has an empty constructor, it’s defined as:
ColorRGBA() = default;
Which is equivalent to:
ColorRGBA()
{
}
This does not initialize the member variable r,g,b and a, leading to undefined values in the original assignment to dst_type[i] .
I assume the default constructor for ColorRGBA is defined to not initialize the member variable on purpose, to prevent unnecessarily paying the cost of initializing when allocating large arrays of ColorRGBA’s which will be written to shortly after.
Should we just add initializing constructors to all types that are used as attributes? Or should we use another way to get a well defined default value in a templated setting like this?