3 ms·
Doesn't this violate strict aliasing? E.g. what if we do this? void foo(struct_a *a, struct_b *b) { a->x = 0; b->x += 1; a->x = 0; } Strict aliasing allow
by orlp 4y ago
Doesn't this violate strict aliasing? E.g. what if we do this?
void foo(struct_a *a, struct_b *b) { a->x = 0; b->x += 1; a->x = 0; }
Strict aliasing allows the compiler to elide the second a->x = 0. But if we use your inheritance scheme using casting of pointers, we could have a == b.