Skip to content

Shift binops appear to mutate their right operand. #152

@froystig

Description

@froystig
Contributor

The following program:

fn main() {
  let uint b = 1u;
  while (b <= 32u) {
    0u << b;
    b <<= 1u;
    log b;
  }
}

Gives the following output:

rt: 8d08:main:main:                       rust: 2 (0x2)
rt: 8d08:main:main:                       rust: 8 (0x8)
rt: 8d08:main:main:                       rust: 2048 (0x800)

The shift-left 0u << b is necessary to make this happen, but 0u >> b and 0u >>> b suffice to reproduce the bug just as well. Also, changing b <<= 1u to b = b << 1u makes the bug go away.

Activity

graydon

graydon commented on Aug 26, 2010

@graydon
Contributor

Make vreg constrs per-quad, regfence on nontrivial constrs, back out workaround to _uint, add regression test. Closed by 7cfa7bd.

added a commit that references this issue on Jul 19, 2017
added a commit that references this issue on Jan 19, 2019
43f7be6
added a commit that references this issue on Oct 1, 2021
c36d17d
added a commit that references this issue on Dec 9, 2021
8434933
added a commit that references this issue on Jun 7, 2022
dac3595
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @graydon@froystig

        Issue actions

          Shift binops appear to mutate their right operand. · Issue #152 · rust-lang/rust