DirectXShaderCompiler
DirectXShaderCompiler copied to clipboard
`bool` cast operator doesn't implicitly trigger
If a struct has a defined cast operator for bool, the expected behavior would be that the struct can be used in if statements and cast to bool implicitly. This currently does not work in the following example.
struct Foo {
int x;
operator bool() {
return x < 5;
}
};
[numthreads(1, 1, 1)]
void main(uint tidx : SV_DispatchThreadId) {
Foo A = {1};
if (A)
A.x += 2;
}
Thank you for reporting this issue. I will take a look.
Pretty sure this is the cause here: https://github.com/microsoft/DirectXShaderCompiler/blob/main/tools/clang/lib/Sema/SemaOverload.cpp#L1136
I'll circle back to this issue at some point.