lib9: gcc-4.2 bug in sprint
diff --git a/src/lib9/fmt/sprint.c b/src/lib9/fmt/sprint.c index 9e3cb63..4155d88 100644 --- a/src/lib9/fmt/sprint.c +++ b/src/lib9/fmt/sprint.c
@@ -16,8 +16,11 @@ /* * 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);