Refine size_of_logic - #2180
Conversation
c399c87 to
083e793
Compare
jhjourdan
left a comment
There was a problem hiding this comment.
I appreciate your efforts in making Creusot proofs portable, but I think this is, unfortunately, doomed to failure.
Indeed, we already depend on the architecture in many places:
- The model of
usizedepends on the architecture, and we are not going to make it generic, because then many proofs will fail. - Typechecking sometimes evaluate
constvalues, andsize_ofis const (hence, typechecking is target-dependent, which you may find ugly, but this is the way it is) - There are already quite a few instances of
#[cfg_attr(target_pointer_width = "16", ...)]in creusot-std
So let's use the value computed by Rustc for size_of when it succeeds doing so, even if the result is not portable.
|
I unfortunately agree about platform independance, this is probably a lost battle; and we can say "verify with Creusot on each architecture you want to release on". |
I agree this is a problem, but again, typechecking (including trait resolution) depends on const evaluation, so this is a lost battle. We may open an issue about that, but basically this means that Creusot is really sound only if the code is linked with the exact same version of Rustc that is used for compilation.
I would really be surprised if that would not be the case (of course, we are assuming same compiler version with the same configuration)! |
083e793 to
3121b37
Compare
3121b37 to
71a22b9
Compare
|
After our discussion, I agree: I opened #2186 to track this, and slightly changed the doc of |
71a22b9 to
6559098
Compare
size_of::<T>() > 0, based on discussion with the Rust team, and in particular this change to the reference that seems close to be accepted: Fields must fit in the type, even for repr(Rust) rust-lang/reference#2166:size_of_logic::<T>()to types where the size is known to be fixed across compilation targets.