Skip to content
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

libstd: modify wrong shift width #6108

Merged
merged 2 commits into from
Apr 30, 2013
Merged

libstd: modify wrong shift width #6108

merged 2 commits into from
Apr 30, 2013

Commits on Apr 29, 2013

  1. Configuration menu
    Copy the full SHA
    e4ca2da View commit details
    Browse the repository at this point in the history
  2. libstd: modify wrong shift width.

    borrow = *elem << (uint::bits - n_bits);
    
    The code above contains a bug that the value of the right operand of the shift operator exceeds the size of the left operand,
    because sizeof(*elem) == 32, and 0 <= n_bits < 32 in 64bit architecture.
    
    If `--opt-level` option is not given to rustc, the code above runs as if the right operand is `(uint::bits - n_bits) % 32`,
    but if --opt-level is given, `borrow` is always zero.
    
    I wonder why this bug is not catched in the libstd's testsuite (I try the `rustc --test --opt-level=2 bigint.rs` before fixing the bug,
    but the unittest passes normally.)
    gifnksm committed Apr 29, 2013
    5 Configuration menu
    Copy the full SHA
    ffa31d2 View commit details
    Browse the repository at this point in the history