-
Notifications
You must be signed in to change notification settings - Fork 93
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
Add minimal example demonstrating -fno-strict-aliasing #630
base: master
Are you sure you want to change the base?
Add minimal example demonstrating -fno-strict-aliasing #630
Conversation
Can you combine the examples into a single .c file, if you really want to have two tests? Can you add a more explanatory comment at the beginning of the .c file, saying more about why this is important? And do you have a theory about why the clight version of this works consistently in all C compilers -- does it have something to do with sequence points? If so, please explain that too in the comment. |
I think combining the files would not be great for clarity, so maybe we can just omit the first one. Is there already an example that demonstrates My understanding of what is going on with If there is no example of int main() {
int x = 0;
return (!x) - (x++);
} As for |
That's all fine, but if you would like to document this within VST more permanently, I suggest:
|
Okay, I just removed the |
a4e4cb3
to
23ac639
Compare
More questions: I presume you are testing your stuff with BITSIZE=32. Can you use size_t instead of int, therefore making your demonstration portable to BITSIZE=64 as well? (Or do I misunderstand, and the whole point is that int is not the same size as (void*). In that case, you could use "short" to make sure your demonstration is portable to both sizeof(void*)=4 and sizeof(void*)=8.) Also, you say "even though int and void * have size and alignment." Do you mean, "even though int and void * have the same size and alignment." And I'm still not sure what the point is. Are you trying to demonstrate that clightgen does not change any properties of the program relevant to strict aliasing, so that the input to clightgen will behave the same as the output of clightgen when compiled with -fno-strict-aliasing, and the input to clightgen will behave the same as the output of clightgen when compiled without -fno-strict-aliasing? And finally, is VST sound if the Clight program is compiled with -fno-strict-aliasing? |
I changed |
Sorry, in 64-bit C compilers, Also, can you add to the comment inside the .c file, the following remarks (if they are accurate): |
I added a comment along the lines of what you suggested. The size of |
I read that VST can be used to verify an idiomatic memory allocator, so I wanted to see if it can be used to verify straightforward memory access as well. Turns out it can!
Edit: The first example goes through as expected just because
clightgen
interpretslong
asint
, so it's not that interesting. The second example uses aint
andvoid *
which remain distinct throughout VST, so the proof actually argues that their memory representations are compatible.