https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61762
--- Comment #18 from rguenther at suse dot de <rguenther at suse dot de> --- On Fri, 1 Aug 2014, froydnj at gcc dot gnu.org wrote: > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61762 > > --- Comment #17 from Nathan Froyd <froydnj at gcc dot gnu.org> --- > (In reply to Richard Biener from comment #15) > > Instead aligned the string. > > This is kind of unfortunate, as the motivating testcase was something more > like: > > ... > static const char string[] = "Private"; > unsigned int priv, riva, ivat, vate; > memcpy(&priv, &string[0], sizeof(priv)); > memcpy(&riva, &string[1], sizeof(riva)) > memcpy(&ivat, &string[2], sizeof(ivat)); > memcpy(&vate, &string[3], sizeof(vate)); > /* proceed to use priv, riva, ivate, vate for comparisons */ > > So on strict-align targets, even if the source string was aligned (and that > has > to be by user-declaration?) we wouldn't catch the latter three? Yes - or "maybe". I will still implement the optimization (see the patch) but it only triggers very late due to the c_strlen wart. OTOH on strict-align targets you get the memcpy expanded which means it's expanded inline if the target likes it to.