Skip to content

Extend kani::mem::same_allocation for Unit Type Pointers #3650

@xsxszab

Description

@xsxszab

Description
The same_allocation API currently cannot accept pointers to unit types as inputs, doing so will result in verification failures. Extending same_allocation to support unit type pointers would enhance its usability, especially for implementing function contracts involving generic typed pointers. This capability would be particularly valuable for use cases like the one discussed here.

Example

#[kani::proof]
fn test_unit_type() {
    let unit_obj = ();
    let ptr1: *const () = &unit_obj;
    let ptr2: *const () = &unit_obj;
    assert!(kani::mem::same_allocation(ptr1, ptr2));
}

Running Kani on this proof produces the following error:

Failed Checks: Kani does not support reasoning about pointers to unallocated memory.

Metadata

Metadata

Assignees

No one assigned

    Labels

    [C] Feature / EnhancementA new feature request or enhancement to an existing feature.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions