-
Notifications
You must be signed in to change notification settings - Fork 722
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Casting subclass to parent of three class heirarchy causes crashes #3048
Comments
A slightly altered shader gives a slightly different crash location that comes a bit earlier. struct A {
float4 stuff;
};
struct B : A {
Texture2D tex; // THIS IS WHAT'S NEW
float4 gimme() {return stuff;}
};
struct C : B {
void dostuff() {stuff = 0;}
};
float4 f(B thing1) { // THIS IS THE PROBLEM
return thing1.gimme();
}
float4 main() : SV_Target
{
C thing2;
thing2.stuff = float4(1,2,3,4);
return f(thing2);
} |
Both of these crashes are in codegen and seem to stem from the expectation that casts of this sort will be limited to simple types rather than structs. |
Compiler Explorer: https://godbolt.org/z/33nncaE4z |
Crash callstack:
|
The crash here is weird, it is crashing codegen-ing a flat conversion, but it should be (and is in the AST) a derived to base conversion. |
Caused by: #2312 Which treats derived-to-base as a flat conversion. That could cause all sorts of things to break. |
btw what happens if you make the |
Derived to base conversions are disallowed on |
The following shader which attempts to cast a variable of type C to its immediate parent, type B while passing an argument crashes DXC. If the only classes are B and C, this works fine. If there is a parent class to B, then it fails. Passing the argument as class C works fine as well.
The text was updated successfully, but these errors were encountered: