https://gcc.gnu.org/bugzilla/show_bug.cgi?id=50417
--- Comment #12 from rguenther at suse dot de <rguenther at suse dot de> --- On Fri, 8 Jul 2016, olegendo at gcc dot gnu.org wrote: > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=50417 > > --- Comment #11 from Oleg Endo <olegendo at gcc dot gnu.org> --- > (In reply to rguent...@suse.de from comment #10) > > > > What makes the parameter type special? Would > > > > void test (const int *a, int *b) > > { > > std::memcpy ((char *)b, (char *)a, t); > > } > > > > be invalid to optimize to an aligned copy in your eyes? > > I think it's perfectly valid to optimize this case. It could as well be > something like: > > void test (const int *a, int *b) > { > a[100] = 1; > b[200] = 2; > > std::memcpy ((char *)b, (char *)a, t); > } > > where a[100] and b[200] both would result in 32 bit accesses, not 4x1 byte or > something, because the base pointer is assumed to be int aligned. No, because the access is performed as 'int'. > Why should memcpy be any different? Because the memcpy stmt doesn't constitute a memory access but a function call.