Skip to content

Overflow checks should abort the execution #1208

Closed

Description

@celinval

I tried this code:

#[kani::proof]
fn check_sub_overflow() {
    let a = [0; 5];
    let ptr0: *const i32 = &a[0];
    let ptr1: *const i32 = &a[1];
    let _: usize = ptr0 as usize - ptr1 as usize;
    unreachable!("Previous statement should fail");
}

using the following command line invocation:

kani check.rs

with Kani version: 0.2

I expected to see this happen: There should be an overflow check failure but the unreachable code should not panic since it is unreachable (playground example).

Instead, this happened: Both checks fail, the overflow check and the unreachable panic.

Activity

  1. added
    [C] Bug
    on May 19, 2022
  2. adpaco commented on May 20, 2022

    @adpaco
    Contributor

    Yes, there are many places where we assert false but we should be using (assert + assume) false. If I'm not mistaken, this would be covered by the "assertions audit" described in #1056.

  3. added a commit that references this issue on May 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    [C] Bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions