You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
DXC exhibits different behavior than FXC when encountering uninitialized variables #2419
Scenario 1: Uninitialized variable
DXC: Below shader compiles fine without any warning.
FXC: Compilation fails with an error message error X4000: variable 'sum' used without having been completely initialized
Scenario 2: Uninitialized variable passed to another function.
DXC: Below shader compiles fine without any warning.
FXC: Compilation fails with an error message error X4000: variable 'sum' used without having been completely initialized
uint foo(uint s)
{
s = s << 4;
return s;
}
uint main(uint i : IN) : OUT
{
uint sum;
return foo(sum);
}
Scenario 3: Uninitialized variable used in its own initialization
DXC: Below shader compiles fine without any warning.
FXC: Compiles fine with a warning message warning X3578: Output value 'main' is not completely initialized
uint main() : OUT
{
uint sum = sum;
return sum;
}
Scenario 4: Returning struct with uninitialized fields
DXC: Below shader compiles fine without any warning.
FXC: Compiles fine with a warning message warning X3578: Output value 'main' is not completely initialized
struct MyStruct {
float a;
int b;
};
MyStruct main() : OUT
{
MyStruct val;
return val;
}
Scenario 5: Conditional initialization
Both DXC and FXC compiles below shader without any warning.
uint main(uint i : IN) : OUT
{
uint sum;
if(i > 10) {
sum = 10;
}
return sum;
}
Vishal Sharma (@vcsharma) We've also noticed this at Unity, do you plan on fixing this anytime soon? Having warnings for uninitialized outputs would be really nice to have.
Activity
vcsharma commentedon Apr 29, 2020
Reopening this issue as the fix for this would be needed along with fix for #2494.
Dredhog commentedon May 3, 2021
Vishal Sharma (@vcsharma) We've also noticed this at Unity, do you plan on fixing this anytime soon? Having warnings for uninitialized outputs would be really nice to have.
damyanp commentedon Jun 12, 2024
No plans to address this in DXC, but this is something we're aware of in clang.