Document that the result of shifting out of bounds varies by platform - #283
Conversation
| For unsigned integers, zeros are shifted in on the left. For signed integers, the sign bit is replicated.\n\n\ | ||
| When shifting out of bounds (e.g. shifting a 32-bit value by 32 or more), the result is implementation-defined and may vary by platform.", |
There was a problem hiding this comment.
Since you mentioned that it might panic in debug mode for fallback, maybe expicitly adding "or panic" might be a good idea?
There was a problem hiding this comment.
Should we just make it consistently panic in debug mode, then?
There was a problem hiding this comment.
For the other backends? I don't think we have to, just would be good to clarify that "implementation-defined" can also include panicking.
There was a problem hiding this comment.
I thought it might be good idea to panic in debug mode here, since doing out-of-bounds shifts and relying on the result is a footgun. But std has explicit wrapping shifts while we don't, so it's probably best not to force panics on people.
We could make fallback wrap instead of panicking; I think that's the best approach, considering the above.
…eason for generated code lint suppressions
Now that I've researched it for #279 (comment), might as well document it.
I also had Codex write tests to probe for other platform divergences and it didn't find anything that isn't already documented, other than differences in how the signalling bit in
NaNs is propagated or not in some ops. But the standard library notes that you "very likely" don't care if a NaN is signalling or not, so I didn't bother documenting that.