Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

panicked at: 'Not sure how to get the size of VoidType' #10

Closed
Badel2 opened this issue Sep 19, 2020 · 2 comments
Closed

panicked at: 'Not sure how to get the size of VoidType' #10

Badel2 opened this issue Sep 19, 2020 · 2 comments

Comments

@Badel2
Copy link

Badel2 commented Sep 19, 2020

I wanted to test if a simple function can panic:

pub fn panic_if_not_zero(x: u32) {
    assert_eq!(x, 0);
}

But haybale panicked at 'Not sure how to get the size of VoidType'. I guess that's because the function returns void and that's not supported.

I tried to patch it by setting the size of VoidType to 0 and it seems to work:

diff --git a/src/project.rs b/src/project.rs
index 058c5ff..d171e2d 100644
--- a/src/project.rs
+++ b/src/project.rs
@@ -350,6 +350,7 @@ impl Project {
                 (NamedStructDef::Opaque, _) => None,
                 (NamedStructDef::Defined(ty), _) => self.size_in_bits(&ty),
             },
+            Type::VoidType => Some(0),
             ty => panic!("Not sure how to get the size of {:?}", ty),
         }
     }
@cdisselkoen
Copy link
Collaborator

Yep, I was able to reproduce this. Haybale definitely supports functions returning void, but get_possible_return_values_of_func() seems like it barfs on void functions. Working on fixing this now.

I think that having size_in_bits() return 0 doesn't completely fix the problem, as size_in_bits() is sometimes used to determine the size of a Boolector BV, and trying to create a Boolector BV of size 0 is an error --- so I think either size_in_bits() needs a different way to indicate void type, or more consumers of size_in_bits() need to check whether it gave them 0 and proceed appropriately.

@cdisselkoen
Copy link
Collaborator

This should be fixed now on master. I also added your simple function as a regression test. Thanks for the report!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants