Skip to content

Create an API to check valid raw pointer #2690

Closed
@celinval

Description

@celinval

Requested feature: Create a method to ensure a pointer is valid.
Use case: Verifying unsafe operations
Link to relevant documentation (Rust reference, Nomicon, RFC):

The method I was thinking would be something like:

pub fn is_ptr_valid<T: ?Sized>(ptr: *const T) -> bool {
    let sz = intrinsics::size_of_val(ptr);
    // Kani intrinsic that translates to __CPROVER_r_ok
    is_read_ok(ptr, sz)
}

Metadata

Metadata

Assignees

Labels

T-CBMCIssue related to an existing CBMC issue[C] Feature / EnhancementA new feature request or enhancement to an existing feature.[E] User ExperienceAn UX enhancement for an existing feature. Including deprecation of an existing one.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions