[wgsl-in] firstLeadingBit returns wrong integer type + unsanitised clamp error #1844
Labels
area: front-end
Input formats for conversion
kind: bug
Something isn't working
lang: WGSL
WebGPU shading language
Milestone
The spec definition for firstLeadingBit seems to suggest that if it's given
0
as an argument, it will return-1
- and if it's0u
specifically, will returnu32(-1)
(i.e. a conversion to keep the return type asu32
). naga seems to be returning ani32
insteadcode:
error:
I found the above after reducing some larger code that errored on compilation - during reduction I saw a (possibly?) unsanitised error as well
code:
error:
My original code was a large switch statement, and the error I got was that my case was a
u32
(i.e. the wrong type for ani32
selector) - since the selector expression contained the above clamp code, it seems like there might be an issue wrt naga accepting that code - i.e. if the clamp is invalid as it says above, the whole selector should surely be invalid instead of being accepted as a legitimate expression returning ani32
value (and therefore myu32
case being the actual problem)? Extracting the selector expression by itself and assigning it to au32
var as above also just gave an incorrect-typing error instead of invalid error. Let me know if dropping that code here also would be useful :)The text was updated successfully, but these errors were encountered: