This is the mail archive of the
mailing list for the GCC project.
Re: movmem pattern and missed alignment
On Mon, 8 Oct 2018, Alexander Monakov wrote:
> > Only if you somewhere visibly add accesses to *i and *j. Without them
> > you only have the "accesses" via memcpy, and as Richi says, those
> > don't imply any alignment requirements. The i and j pointers might
> > validly be char* pointers in disguise and hence be in fact only
> > 1-aligned. I.e. there's nothing in your small example program from
> > which GCC can infer that those two global pointers are in fact
> > 2-aligned.
> Well, it's not that simple. C11 188.8.131.52 p7 makes it undefined to form an
> 'int *' value that is not suitably aligned:
> So in addition to what you said, we should probably say that GCC decides
> not to exploit this UB in order to allow code to round-trip pointer values
> via arbitrary pointer types?
That's correct, I was explaining from the middle-end perspective. There
we are consciously more lenient as we have to support the real world and
other languages than C. This is one of the cases.