Open rayanht opened 2 years ago
This seems needlessly nitpicky. Is this actually undefined, or is just pedantic C89 behavior that has been inherited? There are similar cases with right shift arithmetic that works fine on any compiler, but it's still undefined in C (which Metal inherits from).
What would a suggested workaround look like?
@HansKristian-Work it's actually a bit unclear. I can't find anything about shifting introducing UB in the Metal spec. The Metal validation layers complaining about it might very well be due to behaviour inherited from C.
I don't know what's the course of action here for SPIRV-Cross since the spec and the validation layers seem to diverge. I'd err towards following the spec but I'll also submit a ticket to the Metal bug tracker to clarify this behaviour.
Consider the following shader:
It is seemingly valid in SPIR-V to apply an OpShiftLeftLogical to a negative base:
spirv-cross
emits the following MSL:This is an undefined operation as demonstrated by running the Metal validation layers:
This is a fuzzer-found bug using SPIRVSmith