1 // error-pattern:thread 'main' panicked at 'attempt to shift right with overflow'
2 // compile-flags: -C debug-assertions
4 // This function is checking that our (type-based) automatic
5 // truncation does not sidestep the overflow checking.
7 #![warn(exceeding_bitshifts)]
10 // this signals overflow when checking is on
13 // ... but when checking is off, the fallback will truncate the
14 // input to its lower three bits (= 1). Note that this is *not*
15 // the behavior of the x86 processor for 8- and 16-bit types,
16 // but it is necessary to avoid undefined behavior from LLVM.
18 // We check that here, by ensuring the result is not zero; if
19 // overflow checking is turned off, then this assertion will pass
20 // (and the compiletest driver will report that the test did not
21 // produce the error expected above).