diff options
author | Russ Cox <rsc@swtch.com> | 2008-03-03 23:37:12 -0500 |
---|---|---|
committer | Russ Cox <rsc@swtch.com> | 2008-03-03 23:37:12 -0500 |
commit | 34167aa6b0d7d53016b8574b4fe1fac764ddf615 (patch) | |
tree | 6294118147fac0c0f9c736d2f13415c6cea32557 /src | |
parent | b32d9d9c2e07681450a7ea1801b07e5727fa39e2 (diff) | |
download | plan9port-34167aa6b0d7d53016b8574b4fe1fac764ddf615.tar.gz plan9port-34167aa6b0d7d53016b8574b4fe1fac764ddf615.tar.bz2 plan9port-34167aa6b0d7d53016b8574b4fe1fac764ddf615.zip |
lib9: gcc-4.2 bug in sprint
Diffstat (limited to 'src')
-rw-r--r-- | src/lib9/fmt/sprint.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/lib9/fmt/sprint.c b/src/lib9/fmt/sprint.c index 9e3cb63e..4155d885 100644 --- a/src/lib9/fmt/sprint.c +++ b/src/lib9/fmt/sprint.c @@ -16,8 +16,11 @@ sprint(char *buf, char *fmt, ...) /* * on PowerPC, the stack is near the top of memory, so * we must be sure not to overflow a 32-bit pointer. + * + * careful! gcc-4.2 assumes buf+len < buf can never be true and + * optimizes the test away. casting to uintptr works around this bug. */ - if(buf+len < buf) + if((uintptr)buf+len < (uintptr)buf) len = -(uintptr)buf-1; va_start(args, fmt); |