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

Your byte implementation is unsafe under strict aliasing #3

Closed
ned14 opened this issue Apr 13, 2018 · 2 comments
Closed

Your byte implementation is unsafe under strict aliasing #3

ned14 opened this issue Apr 13, 2018 · 2 comments

Comments

@ned14
Copy link

ned14 commented Apr 13, 2018

As Richard Smith points out in https://groups.google.com/a/isocpp.org/d/msg/std-proposals/McSXSFki08I/fwKKfZqNCAAJ, your byte implementation would be unsafe under strict aliasing optimisation.

The solution is to mark up your byte type with __attribute__((__may_alias__)) on GCC and clang, For MSVC, currently, unless you use __declspec(noalias) and/or __declspec(restrict), everything is assumed to alias, though Microsoft promise that strict aliasing optimisation is coming at some point soon.

@martinmoene
Copy link
Owner

Thanks Niall! Addressed in 75bf4d2

@martinmoene
Copy link
Owner

martinmoene commented Apr 14, 2018

Todo:

  • Add aliasing test

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