summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMikael Pettersson <mikpe@it.uu.se>2013-04-14 10:56:47 +0200
committerTim Angus <tim@ngus.net>2013-05-03 16:10:50 +0100
commit1f6f1c7f6f7843b745e2e6d6a67cd9bf3671d319 (patch)
tree5404373b0262e25d1e43069728a632e5b5d44295
parentf3013ff9b5fef8ac0789c3a12035291a9ad1470d (diff)
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]
-rw-r--r--src/tools/lcc/cpp/unix.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/tools/lcc/cpp/unix.c b/src/tools/lcc/cpp/unix.c
index 17986d84..bd879448 100644
--- a/src/tools/lcc/cpp/unix.c
+++ b/src/tools/lcc/cpp/unix.c
@@ -109,7 +109,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) {
@@ -123,6 +123,6 @@ memmove(void *dp, const void *sp, size_t n)
*--cdp = *--csp;
} while (--n);
}
- return 0;
+ return dp;
}
#endif