diff --git a/src/fn_call.rs b/src/fn_call.rs index e9377d89bc..99459564cf 100644 --- a/src/fn_call.rs +++ b/src/fn_call.rs @@ -560,6 +560,17 @@ pub trait EvalContextExt<'a, 'mir, 'tcx: 'a + 'mir>: crate::MiriEvalContextExt<' let n = this.memory().get(ptr.alloc_id)?.read_c_str(tcx, ptr)?.len(); this.write_scalar(Scalar::from_uint(n as u64, dest.layout.size), dest)?; } + "cbrt" => { + let f = this.read_scalar(args[0])?.to_f64()?; + let n = f.cbrt(); + this.write_scalar(Scalar::from_f64(n), dest)?; + } + "_hypot" | "hypot" => { + let f1 = this.read_scalar(args[0])?.to_f64()?; + let f2 = this.read_scalar(args[1])?.to_f64()?; + let n = f1.hypot(f2); + this.write_scalar(Scalar::from_f64(n), dest)?; + } // Some things needed for `sys::thread` initialization to go through. "signal" | "sigaction" | "sigaltstack" => { diff --git a/tests/run-pass/intrinsics-math.rs b/tests/run-pass/intrinsics-math.rs index a2c5563474..16edea8ac0 100644 --- a/tests/run-pass/intrinsics-math.rs +++ b/tests/run-pass/intrinsics-math.rs @@ -64,4 +64,7 @@ pub fn main() { assert_approx_eq!(0.1f32.trunc(), 0.0f32); assert_approx_eq!((-0.1f64).trunc(), 0.0f64); + + assert_approx_eq!(27f64.cbrt(), 3.0f64); + assert_approx_eq!(3f64.hypot(4f64), 5.0f64); }