This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: movmem pattern and missed alignment


Hi,

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 6.3.2.3 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.


Ciao,
Michael.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]