GCC 4.4: Stricter aliasing requirements

Cristian Ionescu-Idbohrn cristian.ionescu-idbohrn at axis.com
Sun Sep 5 18:28:46 UTC 2010


On Sun, 5 Sep 2010, Denys Vlasenko wrote:

> On Sun, Sep 5, 2010 at 4:59 PM, Cristian Ionescu-Idbohrn
> <cristian.ionescu-idbohrn at axis.com> wrote:
> > On Sun, 5 Sep 2010, Denys Vlasenko wrote:
> >> What do you propose to do?
> >
> > Up to the maintainer ;) But this is the advise:
> >
> >        This can be temporarily worked around by using
> >        -fno-strict-aliasing
>
> Performance hit.
>
> > To fix, access the structure from pointers
> >        of an equivalent type, use a union, use memcpy,
>
> This will be ugly.

I suspected that.

> > or (if using C++)
> >        use placement new. See the section titled "Casting does not work
> >        as expected when optimization is turned on" on bug reporting
> >        documentation page for more information.
> >
> > and points to another page:
> >
> >        http://gcc.gnu.org/bugs/
> >
> > and an article:
> >
> >        http://mail-index.netbsd.org/tech-kern/2003/08/11/0001.html
> >
> > I would vote for fixing the code generating 183+ warnings, but I realize
> > that takes some effort.
>
> Did you already looked at the code which causes this?

No, I didn't.

> Hint: grep -r FIX_ALIASING .

62 hits.  Just 183+ left :)  Is this:

include/platform.h-104-/* At 4.4 gcc become much more anal about this, need to use "aliased" types */
include/platform.h-105-#if __GNUC_PREREQ(4,4)
include/platform.h:106:# define FIX_ALIASING __attribute__((__may_alias__))
include/platform.h-107-#else
include/platform.h:108:# define FIX_ALIASING
include/platform.h-109-#endif

a recipe you sugest to be mechanicaly applied, or do you want to go more
anal than that ;)?


Cheers,

-- 
Cristian


More information about the busybox mailing list