After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 769183 - Use -fno-strict-aliasing for everything
Use -fno-strict-aliasing for everything
Product: GStreamer
Classification: Platform
Component: common
git master
Other Linux
: Normal minor
: 1.13.1
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Reported: 2016-07-26 10:43 UTC by Sebastian Dröge (slomo)
Modified: 2018-02-05 07:55 UTC
See Also:
GNOME target: ---
GNOME version: ---

Description Sebastian Dröge (slomo) 2016-07-26 10:43:51 UTC
+++ This bug was initially created as a clone of Bug #769167 +++

gcc strict aliasing can break code that performs type-punning, unless
said type punning uses unions. See:

for more details.

This basically applies to all code that does things like if I understand correctly.

>  SomeObject *obj = ...;
>  ParentObject *parent = PARENT_OBJECT(obj);
>  obj->foo = 123;
>  parent->foo = 456;
>  some_method(obj) // might see parent->foo == 456 or not

We don't assign struct fields directly much though, need some analysis of the impact of all this.
Comment 1 Martin Kelly 2016-07-26 16:00:35 UTC
The scary thing about the strict aliasing optimization is that it could break with future compiler versions in some pretty subtle ways, even if it works fine today. Therefore I think it's best either to carefully audit all the code for this kind of issue (including the heavily used object macros), or just turn off strict aliasing everywhere. Given the difficulty of the former, turning off strict aliasing may be best, and it's what many other projects have done.

This is another very good article illustrating a subtle breakage:

Some people have very strong opinions about strict aliasing:

And here's a list of things that can go wrong with the optimization:
Comment 2 Tim-Philipp Müller 2018-01-28 21:40:37 UTC
So, I assume we still want to do this?

Should be safe to do in any case, no?

And GLib defaults to it too.
Comment 3 Sebastian Dröge (slomo) 2018-01-29 07:56:34 UTC
It's safe but has potential negative performance impact. However, we should enable it. There's too much code, when using GObject, that does not follow the strict aliasing rules.