Skip to content

Why is native code compiled with -fno-strict-aliasing? #27

Closed

Description

@DoDoENT

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?

Activity

  1. DanAlbert commented on Mar 17, 2016

    @DanAlbert
    Contributor

    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/

  2. DanAlbert commented on Mar 17, 2016

    @DanAlbert
    Contributor

    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?

    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.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions