https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103964
--- Comment #8 from Richard Biener <rguenth at gcc dot gnu.org> --- (In reply to Ilya Maximets from comment #7) > One thing that is not clear to me is if the following code has an UB or not: > > struct member* pos; > struct ovs_list start; > > pos = (struct member *)(void*)((uintptr_t)(&start) - 64); > ovs_list_insert((void *)((uintptr_t)pos + 64), &member->elem); > > ? > > This code works fine. Basically, the question is: can we cast and store > the random (aligned) integer to a pointer type, if we're not going to > perform any kind of pointer arithmetic (using the integer arithmetic for > the ovs_list_insert) nor dereference it, unless it points to the actual > valid object? That should be OK, yes.