This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]