From owner-freebsd-bugs@FreeBSD.ORG Sun Jul 6 23:45:07 2014 Return-Path: Delivered-To: freebsd-bugs@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 89E65B9 for ; Sun, 6 Jul 2014 23:45:07 +0000 (UTC) Received: from kenobi.freebsd.org (kenobi.freebsd.org [IPv6:2001:1900:2254:206a::16:76]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 7154C2211 for ; Sun, 6 Jul 2014 23:45:07 +0000 (UTC) Received: from bugs.freebsd.org ([127.0.1.118]) by kenobi.freebsd.org (8.14.8/8.14.8) with ESMTP id s66Nj7Fj014138 for ; Mon, 7 Jul 2014 00:45:07 +0100 (BST) (envelope-from bugzilla-noreply@freebsd.org) From: bugzilla-noreply@freebsd.org To: freebsd-bugs@FreeBSD.org Subject: [Bug 191674] New: [tests] printf("%tu", (intmax_t)-1) returns UINT64_MAX on i386, not UINT32_MAX Date: Sun, 06 Jul 2014 23:45:07 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Base System X-Bugzilla-Component: kern X-Bugzilla-Version: 11.0-CURRENT X-Bugzilla-Keywords: X-Bugzilla-Severity: Affects Some People X-Bugzilla-Who: yaneurabeya@gmail.com X-Bugzilla-Status: Needs Triage X-Bugzilla-Priority: --- X-Bugzilla-Assigned-To: freebsd-bugs@FreeBSD.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version rep_platform op_sys bug_status bug_severity priority component assigned_to reporter Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: https://bugs.freebsd.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 06 Jul 2014 23:45:07 -0000 https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=191674 Bug ID: 191674 Summary: [tests] printf("%tu", (intmax_t)-1) returns UINT64_MAX on i386, not UINT32_MAX Product: Base System Version: 11.0-CURRENT Hardware: i386 OS: Any Status: Needs Triage Severity: Affects Some People Priority: --- Component: kern Assignee: freebsd-bugs@FreeBSD.org Reporter: yaneurabeya@gmail.com One of the testcases in tools/regression/lib/libc/stdio/test-printbasic.t tests out %tu with -1 and it fails because the testcase is correctly expecting UINT32_MAX, not UINT64_MAX. According to printf(3): " t ptrdiff_t (see note) ptrdiff_t * Note: the t modifier, when applied to a o, u, x, or X conversion, indicates that the argument is of an unsigned type equivalent in size to a ptrdiff_t. " ptrdiff_t on i386 is int32_t (from /usr/include/x86/_types.h): 100 #ifdef __LP64__ 101 typedef __int64_t __ptrdiff_t; /* ptr1 - ptr2 */ ... 109 #else 110 typedef __int32_t __ptrdiff_t; So I would expect the value to be UINT32_MAX. This mismatches with the code in lib/libc/stdio/vfprintf.c vs sys/x86/include/_types.h as intmax_t is always int64_t: 412 #define INTMAX_SIZE (INTMAXT|SIZET|PTRDIFFT|LLONGINT) 413 #define SJARG() \ 414 (flags&INTMAXT ? GETARG(intmax_t) : \ 415 flags&SIZET ? (intmax_t)GETARG(ssize_t) : \ 416 flags&PTRDIFFT ? (intmax_t)GETARG(ptrdiff_t) : \ 417 (intmax_t)GETARG(long long)) 418 #define UJARG() \ 419 (flags&INTMAXT ? GETARG(uintmax_t) : \ 420 flags&SIZET ? (uintmax_t)GETARG(size_t) : \ 421 flags&PTRDIFFT ? (uintmax_t)GETARG(ptrdiff_t) : \ 422 (uintmax_t)GETARG(unsigned long long)) ... 602 case 't': 603 flags |= PTRDIFFT; 604 goto rflag; >From sys/x86/include/_types.h: 91 typedef __int64_t __intmax_t; Logically, I would expect this to be true IFF the i386 architecture was PAE-enabled. # uname -a FreeBSD isilon-fuji-current.local 11.0-CURRENT FreeBSD 11.0-CURRENT #12 r267851+3e60b32(isilon-atf-fix-bsd-progs): Thu Jun 26 12:06:01 PDT 2014 root@isilon-fuji-current.local:/usr/obj/usr/src/sys/FUJI i386 # pwd /usr/src/tools/regression/lib/libc/stdio # prove test-printbasic.t test-printbasic.t .. 80: printf("%tu", (size_t)-1) ==> [18446744073709551615], expected [4294967295] test-printbasic.t .. Failed 2/2 subtests Test Summary Report ------------------- test-printbasic.t (Wstat: 134 Tests: 0 Failed: 0) Non-zero wait status: 134 Parse errors: Bad plan. You planned 2 tests but ran 0. Files=1, Tests=0, 2 wallclock secs ( 0.00 usr 0.04 sys + 0.02 cusr 0.30 csys = 0.36 CPU) Result: FAIL -- You are receiving this mail because: You are the assignee for the bug.