Skip to content

Cleanup codegen_niche_literal #1485

Closed

Description

@fzaiser

Similarly to #1456

Activity

  1. fzaiser commented on Aug 10, 2022

    @fzaiser
    ContributorAuthor

    For reference, the following code:

    #[kani::proof]
    pub fn main() {
        let mut x = Some('a');
        x = None;
    }

    compiles to the following GotoC code under #1486:

    struct std::option::Option<char>::Some
    {
      int 0;
    };
    
    struct std::option::Option<char>
    {
      struct std::option::Option<char>::Some Some;
    };
    
    struct () Void();
    
    struct () main(void)
    {
      struct () var_0;
    bb0:
      struct std::option::Option<char> x=nondet_0();
      x.Some.0 = 97;
      struct std::option::Option<char> tmp_statement_expression;
      struct std::option::Option<char> temp_0;
      *((unsigned int *)((unsigned char *)&temp_0 + 0)) = 1114112;
      tmp_statement_expression = temp_0;
      x = tmp_statement_expression;
      return Void();
    }
    

    So we should be able to transmute the discriminant value to the target type.

  2. self-assigned this
    on Aug 11, 2022
  3. moved this to Done in Kani v0.9on Aug 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions