So, up to now I usually responded to strict aliasing breakage from programs with adding -fno-strict-aliasing to be safe.
In the last days I tried, on Donnie’s suggestion, to investigate of possible solutions to those strict aliasing rules breakage and see if I can fix at least some of them.
I found interestingly that most of the cases that can be found patched on google, and that causes the warnings are not actually involving structs and unions as the gcc documentation shows, but rather double pointers. What’s a double pointer? A pointer to a pointer, of course!
Taking a look to XdTV, I found a quite interesting thing: there is a double-linked list implementation that comes out of AleVT code, that is used by XdTV too. The cause of the warnings come out of lines 20 and 22. I’ll look only at line 20:
h->first = (struct dl_node *)&h->null;
well seems fine no? But wait…
&h->null is a
struct dl_node ** …
And later on,
h->first is going to be used as a
struct dl_node *…
So for some kind of miracle this seems to work, but I’m not that sure that this is something that’s going to work forever.
And there are other casts that works probably only for sheer luck in AleVT’s code. Upstream seems to be dead since 2 years (last update on the site is January 2004), and we don’t have really good alternatives to it…
If someone wants to write something useful to people.. probably a replacement for alevt using zvbi would be useful 😉