Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Test failure of unchecked arithmetic intrinsics in const eval
  • Loading branch information
ecstatic-morse committed Feb 11, 2020
commit ee52fe6d51637c5f877d4a5bd80ec673a277c8d1
22 changes: 22 additions & 0 deletions src/test/ui/consts/const-int-unchecked.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#![feature(core_intrinsics)]
#![feature(const_int_unchecked_arith)]

use std::intrinsics;

Expand Down Expand Up @@ -117,4 +118,25 @@ const SHR_I64_NEG_RANDOM: i64 = unsafe { intrinsics::unchecked_shr(5_i64, -30) }
const SHR_I128_NEG_RANDOM: i128 = unsafe { intrinsics::unchecked_shr(5_i128, -93) };
//~^ ERROR any use of this value will cause an error

// Other arithmetic functions:

const _: u16 = unsafe { std::intrinsics::unchecked_add(40000u16, 30000) };
//~^ ERROR any use of this value will cause an error

const _: u32 = unsafe { std::intrinsics::unchecked_sub(14u32, 22) };
//~^ ERROR any use of this value will cause an error

const _: u16 = unsafe { std::intrinsics::unchecked_mul(300u16, 250u16) };
//~^ ERROR any use of this value will cause an error

const _: i32 = unsafe { std::intrinsics::unchecked_div(1, 0) };
//~^ ERROR any use of this value will cause an error
const _: i32 = unsafe { std::intrinsics::unchecked_div(i32::min_value(), -1) };
//~^ ERROR any use of this value will cause an error

const _: i32 = unsafe { std::intrinsics::unchecked_rem(1, 0) };
//~^ ERROR any use of this value will cause an error
const _: i32 = unsafe { std::intrinsics::unchecked_rem(i32::min_value(), -1) };
//~^ ERROR any use of this value will cause an error

fn main() {}
Loading