Compilation Warnings Related to Uninitialized Struct Fields #4872
Labels
goal:client support
Feature or fix needed for a current slang user.
kind:enhancement
a desirable new feature, option, or behavior
Milestone
Issue Summary:
The provided code produces the following compilation warnings:
These warnings occur in the struct
HitInfo
, which has two fields:float3 barycentrics
anduint primitiveIndex
. The warnings indicate that the constructors (__init
functions) may not be properly initializing these fields.Code Snippet:
Root Cause:
The warnings are triggered because the compiler may not recognize that the
init
function, which is a[[mutating]]
method, properly initializes the struct membersbarycentrics
andprimitiveIndex
. Since these members are not explicitly initialized within the__init
functions themselves, the compiler assumes they might remain uninitialized, hence the warnings.Suggestion for Improvement:
Would it be possible to enhance compiler to check whether
[[mutating]]
functions called within constructors are initializing all the struct members?The text was updated successfully, but these errors were encountered: