something to warry about...

Sergey Naumov sknaumov at
Tue Jan 18 08:59:16 UTC 2011


It seems that there is bug in GCC (at least in gcc 4.3.2) with
attributes for structs in typedefs that developpers do not want to

I don't know what happens with more recent compilers and I have no
warning/error emission even with compiling with -fstrict-aliasing, so
I can propose one more solution but can't test it:

You can declare
typedef struct mii_alias {
    struct mii_ioctl_data m;
} __attribute__(__may_alias__) mii_alias;

static smallint detect_link_priv(void)
        struct ifreq ifreq;
        struct mii_alias *mii = (mii_alias *)&ifreq.ifr_data;
        mii->m.reg_num = 1;

Here we use the fact that pointer to struct is a pointer to its first element.
I do not know internals of the GCC, but at least it is worth to try.

Sergey Naumov.

More information about the busybox mailing list