Strict-aliasing in GCC

Ian Lance Taylor iant@google.com
Sat Jun 12 08:25:00 GMT 2010


Jan Engelhardt <jengelh@medozas.de> writes:

> Since in this particular case, member is the first field,
> one could also write
>
> 	for (pos = (struct item *)clh.next; ...)
>
> I hear that
>
> 	"C specifies that a struct * can be converted to and from a
> 	pointer to its first element."
>
> Does that change anything?

Yes, it should generally be OK to cast between a pointer to a struct
type and a pointer to the type of the first element of the struct.

Ian



More information about the Gcc-help mailing list