Skip to content

Reasoning about ZST addresses #3129

@nishanthkarthik

Description

@nishanthkarthik

I assumed ZST addresses are dangling, so they may or may not be equal for different instances of a type.

I tried this code:

#[repr(C)]
#[derive(Copy, Clone)]
struct Z(i8, i64);

struct Y;

#[kani::proof]
fn test_z() -> Z {
	let m = Y;
	let n = Y;
	let zz = Z(1, -1);
	
	let ptr: *const Z = if &n as *const _ == &m as *const _ {
		std::ptr::null()
	} else {
		&zz
	};
	unsafe{ *ptr }
}

using the following command line invocation:

kani main.rs

with Kani version: 0.48.0

I expected to see this happen: An error because addresses to ZSTs are not guaranteed to have distinct addresses at runtime. Running this snippet crashes playground

Instead, this happened:

...
SUMMARY:
 ** 0 of 7 failed

VERIFICATION:- SUCCESSFUL

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    [C] BugThis is a bug. Something isn't working.[F] SoundnessKani failed to detect an issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions