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
{{ message }}
Repository navigation
Kani generates int constants that cannot fit into their bitwidth on some regressions #996
Enabling the assertion in here causes a whole bunch of regression failures.
pubfnint_constant<T>(i:T,typ:Type) -> SelfwhereT:Into<BigInt>,{assert!(typ.is_integer());let i = i.into();//TODO: This check fails on some regressions// if i != 0 && i != 1 {// assert!(// typ.min_int() <= i && i <= typ.max_int(),// "{} {} {} {:?}",// i,// typ.min_int(),// typ.max_int(),// typ// );// }expr!(IntConstant(i), typ)}
We agreed that there are no soundness concerns (after #1063, of course) because the discriminant values are being correctly encoded in CBMC so they work as expected. Proof of this is for example the test case we have for discriminant values including negative ones in tests/kani/Intrinsics/discriminant_value.rs:
// An enum that assigns constant values (one of them negative) to all variantsenumOrdering{Less = -1,Equal = 0,Greater = 1,}#[kani::proof]fntest_constants_enum(){// Check that the values are equal to the constants assignedassert!(discriminant_value(&Ordering::Less) == -1);assert!(discriminant_value(&Ordering::Equal) == 0);assert!(discriminant_value(&Ordering::Greater) == 1);}
Activity
danielsn commentedon Mar 30, 2022
We can also re-enable the
should_panictests in irep_id.rs once this is fixedadpaco commentedon Mar 30, 2022
Can you please write which regressions were failing?
danielsn commentedon Mar 30, 2022
danielsn commentedon Mar 30, 2022
Looking at the examples, it seems that its mostly a case of the unsigned max value attempting to be put into a signed integer.
danielsn commentedon Mar 30, 2022
e.g.
danielsn commentedon Mar 30, 2022
adpaco commentedon Apr 22, 2022
We agreed that there are no soundness concerns (after #1063, of course) because the discriminant values are being correctly encoded in CBMC so they work as expected. Proof of this is for example the test case we have for discriminant values including negative ones in
tests/kani/Intrinsics/discriminant_value.rs: