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

Deal with strict aliasing issues (-fstrict-aliasing vs -fno-strict-aliasing) #83

Closed
briansmith opened this issue Jan 20, 2016 · 5 comments

Comments

@briansmith
Copy link
Owner

Recently we started building with -fno-strict-aliasing because GCC was warning about strict aliasing, e.g. in https://travis-ci.org/briansmith/ring/jobs/103464242:

crypto/modes/gcm.c:517:5: error: dereferencing type-punned pointer will break strict-aliasing rules [-Werror=strict-aliasing]
     PUTU32(ctx->Yi.c + 12, ctr);
     ^

Building with -fstrict-aliasing is really dangerous unless we're really sure the code is correct with respect to these issues. We can probably avoid turning it off as most of the C code for which it should matter will eventually be written in Rust.

However, we need to at least (a) measure the performance difference, and (b) come up with a plan to address any performance issues we find.

@briansmith briansmith self-assigned this Feb 7, 2016
@briansmith briansmith removed their assignment Dec 12, 2016
@agauniyal
Copy link

Hi, did you ever perform any measurements on the above issue, or changed something else? I'm in a similar boat, was wondering how to solve this problem..

@briansmith
Copy link
Owner Author

I'm in a similar boat, was wondering how to solve this problem..

What is the exact problem you are having? Is it a problem you're having with ring, or a problem with another library?

@agauniyal
Copy link

agauniyal commented Feb 16, 2017

some code of mine, but it includes passing -fno-strict-aliasing in order to be safe. Same warning and everything..

@briansmith
Copy link
Owner Author

I see. I've already removed most pointer casts and most uses of unions from this project, ring, so it's unlikely that we will have to do anything more regarding strict aliasing and we can probably remove -fno-strict-aliasing. OTOH, because we're replacing most of the C code with Rust code, we probably won't benefit from removing the -fno-strict-aliasing anyway, so we might just leave it.

@briansmith
Copy link
Owner Author

briansmith commented Mar 25, 2019

Update:

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

No branches or pull requests

2 participants