lvalue producing flat conversions #355
Labels
language-spec
Issue with completed spec
Theme:Consistency
Issues related to HLSL not being consistent
Milestone
Which document does this relate to?
language
Describe the issue you see with the spec
In talking with @spall about some of the "flat conversion" code she's working on I realized that DXC does allow flat conversions to produce lvalues. We even advertised this as a workaround for HLSL 2021's strict UDT casting rules so that users could add explicit casts on function arguments to convert layout-identical structures.
Enter the problem.
There are actually two code paths in DXC's codegen that implement flat conversions. One in CGExprAgg.cpp which I believe does the right thing (element-wise conversion of each aggregate element), and one in CGExpr.cpp... which doesn't.
The problematic implementation comes from this PR: microsoft/DirectXShaderCompiler#137
Which seems to have been intended to support derived->base conversions, but the CGExpr case actually gets hit in a lot more cases than what the tests reflect, and it triggers in cases like this (which is basically what we told users to do for HLSL 2021):
The problem here is that in the function call S isn't converted to St2 via a flat conversion that performs element-wise conversion, instead it results in a bitcast... Which is very much not correct.
A few immediate thoughts on options:
Additional context
Godbolt
The text was updated successfully, but these errors were encountered: