Strict-aliasing in GCC
Ian Lance Taylor
iant@google.com
Sun Jun 13 23:03:00 GMT 2010
Jan Engelhardt <jengelh@medozas.de> writes:
> struct list_head {
> struct list_head *next;
> };
> struct item {
> struct list_head list;
> };
>
> int main(void)
> {
> struct list_head hdr;
> struct item itm, *pos;
>
> hdr.next = &itm.list;
> itm.list.next = &hdr;
>
> for (pos = (struct item *)hdr.next;
> pos != (struct item *)&hdr;
> pos = (struct item *)(pos->list.next))
> ;
>
> return 0;
> }
I agree that I don't see an aliasing violation in this code.
Ian
More information about the Gcc-help
mailing list