This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Strict-aliasing in GCC
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