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

Enable -Wstrict-aliasing=2 or 1 for RMM #34

Open
soby-mathew opened this issue Nov 5, 2024 · 0 comments
Open

Enable -Wstrict-aliasing=2 or 1 for RMM #34

soby-mathew opened this issue Nov 5, 2024 · 0 comments
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@soby-mathew
Copy link
Member

soby-mathew commented Nov 5, 2024

The compiler may choose to optimize code based on strict aliasing assumptions as documented here : https://en.cppreference.com/w/c/language/object#Strict_aliasing

Although the RMM code tries to avoid this, developers are not infallible and may write code with undefined behavior. Enabling this warning option for the compiler is desirable to flag such code. Whether the option is set to 2 or 1 depends on how many false positives are flagged by the option.

GCC (and presumably Clang) does provide an escape hatch for the situations where it's really necessary to create an aliasing pointer of a different type: https://gcc.gnu.org/onlinedocs/gcc/Common-Type-Attributes.html#index-may_005falias-type-attribute. Hopefully RMM doesn't have such cases but if it does, we should be able to reason about this and be convinced that the aliasing is indeed safe and intentional.

@soby-mathew soby-mathew added enhancement New feature or request good first issue Good for newcomers labels Nov 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

1 participant