Skip to content

Kani should verify the existance of clashing C functions #2426

Open

Description

@celinval

I tried this code:

pub mod a {
    use std::ffi::c_int;
    extern "C" { fn isalpha(_: c_int) -> c_int; }
    pub fn wrap(x: c_int) -> c_int { unsafe { isalpha(x) } }
}

pub mod b {
    use std::ffi::c_int;
    extern "C" { fn isalpha(_: c_int, _: c_int) -> c_int; }
    pub fn wrap(x: c_int, y: c_int) -> c_int { unsafe { isalpha(x, y) } }
}

fn main() {
    let x = a::wrap(10));
    let y = b::wrap(10, 20);
    assert_eq!(x, y);
}

which is a modified version of rust-lang/rust#105146.

using the following command line invocation:

kani -Z c-ffi clashing.rs

with Kani version: 0.27.0

I expected to see this happen: Kani fails due to the clashing definitions

Instead, this happened: Verification succeeds

Activity

  1. added
    [C] BugThis is a bug. Something isn't working.
    on May 3, 2023
  2. added this to the C-FFI Milestone milestone on May 3, 2023
  3. added theissue type on Apr 1, 2026
  4. added
    [E] Unsupported UBUndefined behavior that Kani does not detect
    Z-Kani CompilerIssues that require some changes to the compiler
    on Nov 5, 2026
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

    Z-Kani CompilerIssues that require some changes to the compiler[C] BugThis is a bug. Something isn't working.[E] Unsupported UBUndefined behavior that Kani does not detect

    Type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions