On Saturday, at 19:08, Dennis Ferguson wrote: | gcc can't correctly eliminate the comparison just because you are asking | it to compare pointers to different structure types. No aliasing issues | arise in any case unless you actually use the pointers to access something, | and there are many ways that two pointers of different structure types can | validly refer to the same object.
(I think that) strict aliasing rules implies that if two types "type{1,2}" do not match any of the aliasing rules (e.g. type1 is of the same type as the first member of type2, or type1 is a char, or ...), then any two pointers ptr{1,2} on type{1,2} respectively _ARE_ different, because *ptr1 != *ptr2 per the aliasing rules and this implies ptr1 != ptr2.