[Bug middle-end/32667] block copy with exact overlap is expanded as memcpy
ch3root at openwall dot com
gcc-bugzilla@gcc.gnu.org
Mon Apr 25 19:42:00 GMT 2016
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=32667
--- Comment #17 from Alexander Cherepanov <ch3root at openwall dot com> ---
On 2016-04-25 17:34, joseph at codesourcery dot com wrote:
> Or it could simply document an additional requirement on the C library
> used with GCC (that the case of exact overlap works), just as it documents
> the requirement that some functions such as memcpy be provided even in the
> freestanding case. The compiler and library implementations need to
> cooperate to produce a conforming C implementation.
1. Is glibc community ready to provide such guarantee? The doc[1]
doesn't currently mention an exception for exact overlap.
[1]
https://www.gnu.org/software/libc/manual/html_node/Copying-Strings-and-Arrays.html#index-memcpy
2. I agree that it should be documented. Together with the assumption
that memcpy doesn't clobber errno.
3. The decision affects the whole Free Software community. If memcpy
with exact overlap inserted be gcc are legitimized then users cannot use
tools like valgrind to catch such cases in their own code. (And neither
_FORTIFY_SOURCE nor UBSan seem to catch overlapping memcpy now.) So it
effectively leads to legitimizing such memcpy in user's code too. Making
memcpy closer to a simple assignment (C11, 6.5.16.1p3) could be a good
thing. Maybe even fix C std or POSIX?
BTW llvm bug is here: https://llvm.org/bugs/show_bug.cgi?id=11763 . It
also contains links to valgrind discussions.
More information about the Gcc-bugs
mailing list