Skip to content

deref_box and the is_box() place branch appear unreachable #4858

Description

@srivatsansamraj

Proposed change: add a test that reaches GotocCtx::deref_box (kani-compiler/src/codegen_cprover_gotoc/utils/utils.rs) and the is_box() branch of place codegen that calls it (codegen/place.rs), or remove both. They look unreachable on the current toolchain. rustc's ElaborateBoxDerefs pass rewrites *b on a Box into field projections through Unique and NonNull before Kani sees the body.

Motivation: @feliperodri tested this in review of #4801. He put a panic! at the top of deref_box, and the whole kani suite still passed, 611 of 611:

// kani-compiler/src/codegen_cprover_gotoc/utils/utils.rs, first line of deref_box
panic!("deref_box reached");

let x = *b; and (*boxed_dyn)(&2) both codegen without reaching it.

#4801 kept deref_box in step with box_value, because the two drifting apart caused #4800. But no test can show that half of the change working or breaking. If no MIR reaches the branch after elaboration, removing it leaves two readers of the chain: box_value and codegen_ptr_out_of_wrappers. I can take either option.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions