-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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
overflowing left shift can lead to pseudo-byte with hidden bits #23551
Comments
Ah, this may be hitting an Undefined Behavior scenario in LLVM ... in particular, doing this instead: let x = 2_i8 << id(7_i8); does not seem to yield the same bug. |
okay so this is probably a duplicate of #10183. It is just surprising because it implies that the limit on shift operations is not just 32 or 64 bits, but in fact can be as little as 8 bits (i.e. for an |
closing as duplicate as #10183 |
@pnkfelix indeed the limit is the number of bits in the value being shifted, and I agree this is a dup |
Here is some strange code uncovered by a test I wrote for #23536:
Even in the playpen, this prints:
Note those "crazy, non-matching" left and right values.
(Presumably something with LLVM's low-level code is leaving
x
in a register, thus yielding hidden high-order bits after the shift is done; those need to be masked away before we attempt to compare with another register.)The text was updated successfully, but these errors were encountered: