From 2e145fc176a4f252f20c2ea00350f58724d459f5 Mon Sep 17 00:00:00 2001 From: Mikael Pettersson Date: Sun, 14 Apr 2013 10:56:47 +0200 Subject: [PATCH] Fix memmove() [The lcc source] overrides the libc memmove() with its own implementation, but that implementation fails to follow the specification. In particular, it returns NULL rather than memmove()'s first parameter. GCC now optimizes based on this aspect of the specification, so things go wrong at runtime. [Text & patch from http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56881#c8] --- cpp/unix.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cpp/unix.c b/cpp/unix.c index 400af35d..2dfabfd0 100755 --- a/cpp/unix.c +++ b/cpp/unix.c @@ -98,7 +98,7 @@ memmove(void *dp, const void *sp, size_t n) unsigned char *cdp, *csp; if (n==0) - return 0; + return dp; cdp = dp; csp = (unsigned char *)sp; if (cdp < csp) { @@ -112,5 +112,5 @@ memmove(void *dp, const void *sp, size_t n) *--cdp = *--csp; } while (--n); } - return 0; + return dp; }