Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.
Sign upWhy is native code compiled with -fno-strict-aliasing? #27
Comments
This comment has been minimized.
This comment has been minimized.
Because at some point in the past someone thought they were smarter than the compiler. I actually discovered this while fixing a different bug the other day and cleaned it all up. In r12, I've removed all of the compiler options we were adding that really should just be the compiler's (or user's) decision: https://android-review.googlesource.com/#/c/207721/ |
This comment has been minimized.
This comment has been minimized.
If I had to guess, it was disabled because it does allow the compiler to make some rather surprising optimizations. A lot of developers do not well understand strict aliasing rules, so I guess the idea was that we were protecting people from bugs? It's honestly not a bad idea, and I considered keeping that flag, but I figure keeping compiler behavior consistent across platforms is better. |
I've noticed this being true for quite a long time (also in r10 and probably earlier).
Is there some problem with using
-fstrict-aliasing
when compiling native code? Are there any incompatibilities, undefined behaviour one should watch for when using this optimisation flag?