You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Requested feature: Add support to the new C string literal.
Use case: Users interacting with C code will likely take advantage of C string in the future. This will be specially helpful when we add proper support to CFFI.
Link to relevant documentation (Rust reference, Nomicon, RFC): https://rust-lang.github.io/rfcs/3348-c-str-literal.html
Test case:
#![feature(rustc_private)]#![feature(c_str_literals)]externcrate libc;use libc::c_char;#[kani::proof]fncheck_c_str(){assert_eq!(unsafe{*empty_c_str()},0);let(s, len) = non_empty_c_str();assert_ne!(unsafe{*s.offset(0)},0);assert_eq!(unsafe{*s.offset(len asisize)},0);}fnempty_c_str() -> *constc_char{c"".as_ptr()as*constc_char}/// Return a C string and its length (without the null character).fnnon_empty_c_str() -> (*constc_char,usize){(c"hi".as_ptr()as*constc_char,2)}
Note that C string literal has been stabilized in Rust 1.77 for edition 2021 and above. So the test no longer needs any feature gate:
// RUSTFLAGS=--edition=2021use std::ffi::c_char;#[kani::proof]fncheck_c_str(){assert_eq!(unsafe{*empty_c_str()},0);let(s, len) = non_empty_c_str();assert_ne!(unsafe{*s.offset(0)},0);assert_eq!(unsafe{*s.offset(len asisize)},0);}fnempty_c_str() -> *constc_char{c"".as_ptr()as*constc_char}/// Return a C string and its length (without the null character).fnnon_empty_c_str() -> (*constc_char,usize){(c"hi".as_ptr()as*constc_char,2)}
$ cargo kani -Z unstable-options --harness cstr_lit --harness-timeout 5m
- C string literal (1)
- Description: "C string literal is not currently supported by Kani. Please post your example at https://github.com/model-checking/kani/issues/2549"
Failed Checks: C string literal is not currently supported by Kani. Please post your example at https://github.com/model-checking/kani/issues/2549
VERIFICATION:- FAILED
Context: we ran AI agents that use the Kani agent plugin (#5059) to verify 101 of the most downloaded crates on crates.io with Kani 0.68.0, CBMC 6.11.0 and nightly-2026-10-22. The minimal reproducer above was re-run by hand with the same versions. This text was written with AI assistance.
Activity
celinval commentedon Nov 5, 2024
Note that C string literal has been stabilized in Rust 1.77 for edition 2021 and above. So the test no longer needs any feature gate:
feliperodri commentedon Nov 6, 2026
More evidence for this issue. Kani hit it while verifying these 2 crate(s):
Minimal reproducer (Kani 0.68.0):
Context: we ran AI agents that use the Kani agent plugin (#5059) to verify 101 of the most downloaded crates on crates.io with Kani 0.68.0, CBMC 6.11.0 and nightly-2026-10-22. The minimal reproducer above was re-run by hand with the same versions. This text was written with AI assistance.