<p dir="auto">Here is some strange code uncovered by a test I wrote for <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="63116688" data-permission-text="Title is private" data-url="https://github.com/rust-lang/rust/issues/23536" data-hovercard-type="pull_request" data-hovercard-url="/rust-lang/rust/pull/23536/hovercard" href="https://github.com/rust-lang/rust/pull/23536">#23536</a>:</p>
<div class="highlight highlight-source-rust notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="fn id&lt;T&gt;(x: T) -&gt; T { x }

fn main() {
    let spot: Option&lt;i8&gt;;
    let x = 1_i8 &lt;&lt; id(8_i8);
    spot = Some(x);
    assert_eq!(spot.unwrap(), 0);
    println!(&quot;so we stored a zero byte ... but:&quot;);
    assert_eq!(x, 0);
}"><pre class="notranslate"><span class="pl-k">fn</span> <span class="pl-en">id</span><span class="pl-kos">&lt;</span><span class="pl-smi">T</span><span class="pl-kos">&gt;</span><span class="pl-kos">(</span><span class="pl-s1">x</span><span class="pl-kos">:</span> <span class="pl-smi">T</span><span class="pl-kos">)</span> -&gt; <span class="pl-smi">T</span> <span class="pl-kos">{</span> x <span class="pl-kos">}</span>

<span class="pl-k">fn</span> <span class="pl-en">main</span><span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
    <span class="pl-k">let</span> spot<span class="pl-kos">:</span> <span class="pl-smi">Option</span><span class="pl-kos">&lt;</span><span class="pl-smi">i8</span><span class="pl-kos">&gt;</span><span class="pl-kos">;</span>
    <span class="pl-k">let</span> x = <span class="pl-c1">1_i8</span> &lt;&lt; <span class="pl-en">id</span><span class="pl-kos">(</span><span class="pl-c1">8_i8</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
    spot = <span class="pl-v">Some</span><span class="pl-kos">(</span>x<span class="pl-kos">)</span><span class="pl-kos">;</span>
    <span class="pl-en">assert_eq</span><span class="pl-en">!</span><span class="pl-kos">(</span>spot.unwrap<span class="pl-kos">(</span><span class="pl-kos">)</span>, <span class="pl-c1">0</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
    <span class="pl-en">println</span><span class="pl-en">!</span><span class="pl-kos">(</span><span class="pl-s">"so we stored a zero byte ... but:"</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
    <span class="pl-en">assert_eq</span><span class="pl-en">!</span><span class="pl-kos">(</span>x, <span class="pl-c1">0</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
<span class="pl-kos">}</span></pre></div>
<p dir="auto">Even in the <a href="http://is.gd/DmEuze" rel="nofollow">playpen</a>, this prints:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="so we stored a zero byte ... but:
thread '&lt;main&gt;' panicked at 'assertion failed: `(left == right) &amp;&amp; (right == left)` (left: `0`, right: `0`)', &lt;anon&gt;:9
playpen: application terminated with error code 101"><pre class="notranslate"><code class="notranslate">so we stored a zero byte ... but:
thread '&lt;main&gt;' panicked at 'assertion failed: `(left == right) &amp;&amp; (right == left)` (left: `0`, right: `0`)', &lt;anon&gt;:9
playpen: application terminated with error code 101
</code></pre></div>
<p dir="auto">Note those "crazy, non-matching" left and right values.</p>
<p dir="auto">(Presumably something with LLVM's low-level code is leaving <code class="notranslate">x</code> 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.)</p>
<div class="highlight highlight-source-rust notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="1 &gt;&gt; 24353125315"><pre class="notranslate"><span class="pl-c1">1</span> &gt;&gt; <span class="pl-c1">24353125315</span></pre></div>