You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi @carolynzech @celinval @feliperodri @zhassan-aws
When I was testing my harness for f32::to_int_unchecked, I encountered the error indicating that float_to_int_unchecked is not currently supported by Kani, as shown below. Is it possible to support it?
SUMMARY:
** 1 of 1277 failed (1276 undetermined)
Failed Checks: float_to_int_unchecked is not currently supported by Kani. Please post your example at https://github.com/model-checking/kani/issues/new/choose
File: "/Users/yew005/Docs/Academic/CMU/Fall24/practicum/verify-rust-std/library/core/src/convert/num.rs", line 30, in <f32 as convert::num::FloatToInt<i32>>::to_int_unchecked
VERIFICATION:- FAILED
** WARNING: A Rust construct that is not currently supported by Kani was found to be reachable. Check the results for more details.
Verification Time: 5.8839436s
Summary:
Verification failed for - num::verify::checked_to_int_unchecked_f32
Complete - 0 successfully verified harnesses, 1 failures, 1 total.
library/core/src/convert/num.rs Line 20 to 35:
20macro_rules! impl_float_to_int {21($Float:ty => $($Int:ty),+) => {22 #[unstable(feature = "convert_float_to_int", issue = "67057")]23impl private::Sealedfor $Float {}24 $(25 #[unstable(feature = "convert_float_to_int", issue = "67057")]26implFloatToInt<$Int> for $Float {27 #[inline]28unsafefn to_int_unchecked(self) -> $Int {29// SAFETY: the safety contract must be upheld by the caller.30unsafe{crate::intrinsics::float_to_int_unchecked(self)}31}32}33)+
34}35}
Test harness:
#[kani::proof_for_contract(f32::to_int_unchecked)]pubfnchecked_to_int_unchecked_f32(){let num1:f32 = kani::any::<f32>();let result = unsafe{ num1.to_int_unchecked::<i32>()};assert_eq!(result, num1 asi32);}
Contracts added to f32::to_int_unchecked (in library/core/src/num/f32.rs):
/// # Safety////// The value must:////// * Not be `NaN`/// * Not be infinite/// * Be representable in the return type `Int`, after truncating off its fractional part/// ...#[requires(!self.is_nan() && !self.is_infinite())]#[requires(self >= Self::MIN && self <= Self::MAX)]pubunsafefnto_int_unchecked<Int>(self) -> IntwhereSelf:FloatToInt<Int>,{ ...}
When I was testing my harness for
f32::to_int_unchecked
, I encountered the error indicating that float_to_int_unchecked is not currently supported by Kani, as shown below. Is it possible to support it?library/core/src/convert/num.rs
Line 20 to 35:Test harness:
Contracts added to
f32::to_int_unchecked
(inlibrary/core/src/num/f32.rs
):Thank you very much!
Originally posted by @Yenyun035 in model-checking/verify-rust-std#59 (comment)
The text was updated successfully, but these errors were encountered: