-
Notifications
You must be signed in to change notification settings - Fork 101
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix missing function declaration issue
In cases where a function pointer is created, but its value is never used, Kani crashes due to missing function declaration. For now, collect any instance that has its address taken even if its never used. Fixes #3799
- Loading branch information
Showing
2 changed files
with
43 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// Copyright Kani Contributors | ||
// SPDX-License-Identifier: Apache-2.0 OR MIT | ||
//! Ensure Kani can codegen code with a pointer to a function that is never used | ||
//! See <https://github.com/model-checking/kani/issues/3799> for more details. | ||
fn foo<F: Fn()>(_func: &mut F) {} | ||
fn foo_dyn(_func: &mut dyn Fn()) {} | ||
|
||
#[kani::proof] | ||
fn check_foo() { | ||
fn f() {} | ||
|
||
foo(&mut f); | ||
} | ||
|
||
#[kani::proof] | ||
fn check_foo_dyn() { | ||
fn f() {} | ||
|
||
foo_dyn(&mut f); | ||
} | ||
|
||
#[kani::proof] | ||
fn check_foo_unused() { | ||
fn f() {} | ||
|
||
let ptr = &mut f; | ||
} |