Question about unaligned pointer

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,
With -Waddress-of-packed-member option, GCC gives warning message if
address of packed structure member is taken and assigned to pointer,
like:
struct foo {
    char a;
    int b;
} __attribute__((packed));

int main()
{
    struct foo foo;
    int *p;
    p = &foo.b;  // !!
    *p = 1234;
    return 0;
}

This is expected, however, I wonder if there is any way to let gcc
know that `p` is a pointer that might be unaligned, so that an
unaligned access instruction is generated if `p` is dereferenced?
IIRC, microsoft compiler has __unaligned keyword extended for pointer
declaration.

Thanks,
bin



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux