https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70178
--- Comment #3 from rguenther at suse dot de <rguenther at suse dot de> --- On Fri, 11 Mar 2016, zackw at panix dot com wrote: > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70178 > > --- Comment #2 from Zack Weinberg <zackw at panix dot com> --- That was > my working hypothesis as well. Isn't there some way we can annotate > s->data to reassure the compiler that *this* char* doesn't alias? I > don't know enough about the guts of std::string to know whether > 'restrict' is accurate, but it certainly shouldn't be pointing to > anything but string contents. We can use 'restrict', yes, but it will only have an effect if used on an object a function parameter points to. We do use it on valarray for example. Not sure if it is valid for std::string. Note that using restrict on data members is poorly specified (if at all) and I can't find it specified for C++ at all (just for C). I only find in 17.2 (C++14) that for C standard library functions "any use of the restrict qualifier shall be omitted" ... We do use the restrict feature for fortran arrray descriptors and it works there (as function parameter).