[Bug 191674] New: [tests] printf("%tu", (intmax_t)-1) returns UINT64_MAX on i386, not UINT32_MAX
bugzilla-noreply at freebsd.org
bugzilla-noreply at freebsd.org
Sun Jul 6 23:45:07 UTC 2014
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 at FreeBSD.org
Reporter: yaneurabeya at 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 at 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.
More information about the freebsd-bugs
mailing list