misc/131880: printf("%zi", (ssize_t) -1) prints 4294967292 (unsigned) value instead of -1

Javier Villavicencio the_paya at gentoo.org
Thu Feb 19 08:40:05 PST 2009


>Number:         131880
>Category:       misc
>Synopsis:       printf("%zi", (ssize_t) -1) prints 4294967292 (unsigned) value instead of -1
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Feb 19 16:40:04 UTC 2009
>Closed-Date:
>Last-Modified:
>Originator:     Javier Villavicencio
>Release:        7.1-RELEASE
>Organization:
Gentoo
>Environment:
FreeBSD  7.1-RELEASE FreeBSD 7.1-RELEASE #0: Thu Jan  1 14:37:25 UTC 2009     root at logan.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC  i386
>Description:
Argument for %zi (or %zd) printf format is treated as unsigned while it should be signed.

See also:
http://mail-index.netbsd.org/current-users/2009/02/19/msg008168.html
>How-To-Repeat:
Testcase:

#include <stdio.h>
#include <sys/types.h>

int main(int argc, char **argv)
{
    printf("%zi\n", (ssize_t)-argc);
    return 0;
}

>Fix:
Perhaps http://mail-index.netbsd.org/current-users/2009/02/19/msg008168.html

>Release-Note:
>Audit-Trail:
>Unformatted:


More information about the freebsd-bugs mailing list