Skip to content
Browse files

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]
  • Loading branch information...
1 parent 384af87 commit 836e85e2087401b9d86a9ee83769d63891076fae Mikael Pettersson committed with dsalt Apr 14, 2013
Showing with 2 additions and 2 deletions.
  1. +2 −2 src/tools/lcc/cpp/unix.c
View
4 src/tools/lcc/cpp/unix.c
@@ -110,7 +110,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) {
@@ -124,6 +124,6 @@ memmove(void *dp, const void *sp, size_t n)
*--cdp = *--csp;
} while (--n);
}
- return 0;
+ return dp;
}
#endif

0 comments on commit 836e85e

Please sign in to comment.
Something went wrong with that request. Please try again.