The NetBSD Project

CVS log for src/tests/lib/libc/stdio/t_printf.c

[BACK] Up to [cvs.NetBSD.org] / src / tests / lib / libc / stdio

Request diff between arbitrary revisions


Keyword substitution: kv
Default branch: MAIN


Revision 1.8.42.2: download - view: text, markup, annotated - select for diffs
Thu Aug 22 19:59:46 2024 UTC (5 months ago) by martin
Branches: netbsd-10
CVS tags: netbsd-10-1-RELEASE
Diff to: previous 1.8.42.1: preferred, colored; branchpoint 1.8: preferred, colored; next MAIN 1.9: preferred, colored
Changes since revision 1.8.42.1: +69 -5 lines
Pull up following revision(s) (requested by riastradh in ticket #787):

	tests/lib/libc/stdio/t_printf.c: revision 1.17
	tests/lib/libc/stdio/t_printf.c: revision 1.18
	lib/libc/gdtoa/hdtoa.c: revision 1.13
	tests/lib/libc/stdio/t_printf.c: revision 1.11
	tests/lib/libc/stdio/t_printf.c: revision 1.12
	tests/lib/libc/stdio/t_printf.c: revision 1.13
	tests/lib/libc/stdio/t_printf.c: revision 1.14
	tests/lib/libc/stdio/t_printf.c: revision 1.15
	tests/lib/libc/stdio/t_printf.c: revision 1.16

tests/lib/libc/stdio/t_printf: Add a couple simple %La tests.

PR lib/56937: printf(3) long double %a formatting is broken
tests/lib/libc/stdio/t_printf: Fix %La test.
0xa.99ap+0 is closer to (long double)10.6 in x86 ld80 and in
binary128 (and possibly more formats, haven't verified).
tests/lib/libc/stdio/t_printf: Fix %a test the same way.
tests/lib/libc/stdio/t_printf: Add another %La test.

This one was adapted from the screw case shown in
https://mail-index.netbsd.org/tech-userlevel/2020/04/11/msg012329.html
which wasn't broken in our libc, but which nevertheless prompted us
to commit a wrong and apparently untested patch that has rendered
printf %La broken for the last four years, which is a little
embarrassing.  (The part of that patch that led to a buffer overrun
has been worked around, so now the output is just incorrect.)

PR lib/56937: printf(3) long double %a formatting is broken

Revert various broken changes to printf %La (hldtoa).
This reverts:
hdtoa.c 1.12 (PR/56247: Greg A. Woods: printf("%La", LDBL_MIN) dumps core)
hdtoa.c 1.11 (fix tyop)
hdtoa.c 1.10 (Via enh at google dot com in tech-userlevel. Fix handling of
    EXT_FRAC{H,L}BITS (although we don't need to since we don't have them).)

The underlying motivation for this change was that when ld128 is
decomposed into 4x32 words, this hldtoa logic is broken.

But we don't decompose ld128 into 4x32 words; we decompose it into
6x64 words.

And the change, which was supposed to be a noop in our case of 2x64
words (or similar for x87 80-bit floating-point), broke it to the
point of causing buffer overruns (PR 56247) which when worked around
led to just incorrect output output (PR 56937).
If we want to make the #ifdefs for 4x32 words work, that's fine, but
we absolutely must have automatic test cases to detect this kind of
regression because %La formatting is extremely important for
diagnosing details of floating-point data since it doesn't involve
rounding in binary formats.  For now I've added some trivial tests;
there is a more extensive test suite inside gdtoa that we need to
wire up before anyone tries any other shenanigans in this code.

PR lib/56937: printf(3) long double %a formatting is broken
tests/lib/libc/stdio/t_printf: Fix another rounding error.
Noted by kre.

This doesn't break a passing test or fix a failed test, at least on
x86 -- our printf produces `0x1.533p+3' for the double case and
`0xa.99ap+0' for the long double case.  But of the hexadecimal number
literals that that start with 0x5 having three hexadigits to the
right of the fractional point, 0x5.4cdp+1 closest to the IEEE 754
binary64, VAX D, x86 extended precision, and IEEE 754 binary128
floating-point numbers closest to 10.6.

The reason is that the number 10.6 (or the nearest floating-point
number in any format with enough precision) is:
101.0100 1100 1100|1100... * 2^1 = 0x5.4cc|c...p+1
If we round at the vertical bar to the _nearest_ output with three
hexadigits of precision, the result is:
101.0100 1100 1101 * 2^1 = 0x5.4cdp+1
tests/lib/libc/stdio/t_printf: Fix typo in ld128 case.
printf %La does not write the `L' suffix.
tests/lib/libc/stdio/t_printf: Fix sign error in ld128 case.

Also link back to where the test case came from.

Revision 1.8.34.2: download - view: text, markup, annotated - select for diffs
Thu Aug 22 19:53:56 2024 UTC (5 months ago) by martin
Branches: netbsd-9
Diff to: previous 1.8.34.1: preferred, colored; branchpoint 1.8: preferred, colored; next MAIN 1.9: preferred, colored
Changes since revision 1.8.34.1: +69 -5 lines
Pull up following revision(s) (requested by riastradh in ticket #1866):

	tests/lib/libc/stdio/t_printf.c: revision 1.17
	tests/lib/libc/stdio/t_printf.c: revision 1.18
	tests/lib/libc/stdio/t_printf.c: revision 1.11
	tests/lib/libc/stdio/t_printf.c: revision 1.12
	tests/lib/libc/stdio/t_printf.c: revision 1.13
	tests/lib/libc/stdio/t_printf.c: revision 1.14
	tests/lib/libc/stdio/t_printf.c: revision 1.15
	tests/lib/libc/stdio/t_printf.c: revision 1.16
	(all via patch)

tests/lib/libc/stdio/t_printf: Add a couple simple %La tests.

PR lib/56937: printf(3) long double %a formatting is broken
tests/lib/libc/stdio/t_printf: Fix %La test.
0xa.99ap+0 is closer to (long double)10.6 in x86 ld80 and in
binary128 (and possibly more formats, haven't verified).
tests/lib/libc/stdio/t_printf: Fix %a test the same way.
tests/lib/libc/stdio/t_printf: Add another %La test.

This one was adapted from the screw case shown in
https://mail-index.netbsd.org/tech-userlevel/2020/04/11/msg012329.html
which wasn't broken in our libc, but which nevertheless prompted us
to commit a wrong and apparently untested patch that has rendered
printf %La broken for the last four years, which is a little
embarrassing.  (The part of that patch that led to a buffer overrun
has been worked around, so now the output is just incorrect.)

PR lib/56937: printf(3) long double %a formatting is broken
tests/lib/libc/stdio/t_printf: Fix another rounding error.
Noted by kre.

This doesn't break a passing test or fix a failed test, at least on
x86 -- our printf produces `0x1.533p+3' for the double case and
`0xa.99ap+0' for the long double case.  But of the hexadecimal number
literals that that start with 0x5 having three hexadigits to the
right of the fractional point, 0x5.4cdp+1 closest to the IEEE 754
binary64, VAX D, x86 extended precision, and IEEE 754 binary128
floating-point numbers closest to 10.6.

The reason is that the number 10.6 (or the nearest floating-point
number in any format with enough precision) is:
101.0100 1100 1100|1100... * 2^1 = 0x5.4cc|c...p+1

If we round at the vertical bar to the _nearest_ output with three
hexadigits of precision, the result is:
101.0100 1100 1101 * 2^1 = 0x5.4cdp+1

tests/lib/libc/stdio/t_printf: Fix typo in ld128 case.
printf %La does not write the `L' suffix.

tests/lib/libc/stdio/t_printf: Fix sign error in ld128 case.
Also link back to where the test case came from.

Revision 1.8.34.1: download - view: text, markup, annotated - select for diffs
Thu Aug 22 19:40:50 2024 UTC (5 months ago) by martin
Branches: netbsd-9
Diff to: previous 1.8: preferred, colored
Changes since revision 1.8: +50 -1 lines
Pull up following revision(s) (requested by riastradh in ticket #1865):

	lib/libc/stdio/Makefile.inc: revision 1.48
	tests/lib/libc/stdio/t_printf.c: revision 1.9
	lib/libc/stdio/vfwprintf.c: revision 1.40
	lib/libc/include/extern.h: revision 1.27
	tests/lib/libc/stdio/t_printf.c: revision 1.10

PR/57250: Martin Husemann: dtoa mishandles infinite doubles on 32bit big
endian machines. When long double support was added, the old code was kept
for the regular double code. This code was never used because WIDE_DOUBLE
was always defined in the Makefile. Remove that old code, and conditionalize
the WIDE_DOUBLE code based on if long doubles are different than doubles on
the specific platform.

Add a test for PR/57250 from Havard Eidnes

Fix the test for "inf" output, also include newline in printf format...

Revision 1.18: download - view: text, markup, annotated - select for diffs
Sat May 11 14:39:53 2024 UTC (8 months, 2 weeks ago) by riastradh
Branches: MAIN
CVS tags: perseant-exfatfs-base-20240630, perseant-exfatfs-base, perseant-exfatfs, HEAD
Diff to: previous 1.17: preferred, colored
Changes since revision 1.17: +7 -2 lines
tests/lib/libc/stdio/t_printf: Fix sign error in ld128 case.

Also link back to where the test case came from.

Revision 1.17: download - view: text, markup, annotated - select for diffs
Sat May 11 14:33:23 2024 UTC (8 months, 2 weeks ago) by riastradh
Branches: MAIN
Diff to: previous 1.16: preferred, colored
Changes since revision 1.16: +2 -2 lines
tests/lib/libc/stdio/t_printf: Fix typo in ld128 case.

printf %La does not write the `L' suffix.

Revision 1.16: download - view: text, markup, annotated - select for diffs
Thu May 9 22:38:29 2024 UTC (8 months, 2 weeks ago) by riastradh
Branches: MAIN
Diff to: previous 1.15: preferred, colored
Changes since revision 1.15: +3 -3 lines
tests/lib/libc/stdio/t_printf: Fix another rounding error.

Noted by kre.

This doesn't break a passing test or fix a failed test, at least on
x86 -- our printf produces `0x1.533p+3' for the double case and
`0xa.99ap+0' for the long double case.  But of the hexadecimal number
literals that that start with 0x5 having three hexadigits to the
right of the fractional point, 0x5.4cdp+1 closest to the IEEE 754
binary64, VAX D, x86 extended precision, and IEEE 754 binary128
floating-point numbers closest to 10.6.

The reason is that the number 10.6 (or the nearest floating-point
number in any format with enough precision) is:

101.0100 1100 1100|1100... * 2^1 = 0x5.4cc|c...p+1

If we round at the vertical bar to the _nearest_ output with three
hexadigits of precision, the result is:

101.0100 1100 1101 * 2^1 = 0x5.4cdp+1

Revision 1.15: download - view: text, markup, annotated - select for diffs
Thu May 9 12:24:24 2024 UTC (8 months, 2 weeks ago) by riastradh
Branches: MAIN
Diff to: previous 1.14: preferred, colored
Changes since revision 1.14: +1 -4 lines
Revert various broken changes to printf %La (hldtoa).

This reverts:

hdtoa.c 1.12 (PR/56247: Greg A. Woods: printf("%La", LDBL_MIN) dumps core)
hdtoa.c 1.11 (fix tyop)
hdtoa.c 1.10 (Via enh at google dot com in tech-userlevel. Fix handling of
    EXT_FRAC{H,L}BITS (although we don't need to since we don't have them).)

The underlying motivation for this change was that when ld128 is
decomposed into 4x32 words, this hldtoa logic is broken.

But we don't decompose ld128 into 4x32 words; we decompose it into
6x64 words.

And the change, which was supposed to be a noop in our case of 2x64
words (or similar for x87 80-bit floating-point), broke it to the
point of causing buffer overruns (PR 56247) which when worked around
led to just incorrect output output (PR 56937).

If we want to make the #ifdefs for 4x32 words work, that's fine, but
we absolutely must have automatic test cases to detect this kind of
regression because %La formatting is extremely important for
diagnosing details of floating-point data since it doesn't involve
rounding in binary formats.  For now I've added some trivial tests;
there is a more extensive test suite inside gdtoa that we need to
wire up before anyone tries any other shenanigans in this code.

PR lib/56937: printf(3) long double %a formatting is broken

Revision 1.14: download - view: text, markup, annotated - select for diffs
Wed May 8 20:23:15 2024 UTC (8 months, 2 weeks ago) by riastradh
Branches: MAIN
Diff to: previous 1.13: preferred, colored
Changes since revision 1.13: +21 -1 lines
tests/lib/libc/stdio/t_printf: Add another %La test.

This one was adapted from the screw case shown in

https://mail-index.netbsd.org/tech-userlevel/2020/04/11/msg012329.html

which wasn't broken in our libc, but which nevertheless prompted us
to commit a wrong and apparently untested patch that has rendered
printf %La broken for the last four years, which is a little
embarrassing.  (The part of that patch that led to a buffer overrun
has been worked around, so now the output is just incorrect.)

PR lib/56937: printf(3) long double %a formatting is broken

Revision 1.13: download - view: text, markup, annotated - select for diffs
Wed May 8 20:19:37 2024 UTC (8 months, 2 weeks ago) by riastradh
Branches: MAIN
Diff to: previous 1.12: preferred, colored
Changes since revision 1.12: +2 -2 lines
tests/lib/libc/stdio/t_printf: Fix %a test the same way.

Revision 1.12: download - view: text, markup, annotated - select for diffs
Wed May 8 20:04:33 2024 UTC (8 months, 2 weeks ago) by riastradh
Branches: MAIN
Diff to: previous 1.11: preferred, colored
Changes since revision 1.11: +2 -2 lines
tests/lib/libc/stdio/t_printf: Fix %La test.

0xa.99ap+0 is closer to (long double)10.6 in x86 ld80 and in
binary128 (and possibly more formats, haven't verified).

Revision 1.11: download - view: text, markup, annotated - select for diffs
Wed May 8 18:19:57 2024 UTC (8 months, 2 weeks ago) by riastradh
Branches: MAIN
Diff to: previous 1.10: preferred, colored
Changes since revision 1.10: +47 -5 lines
tests/lib/libc/stdio/t_printf: Add a couple simple %La tests.

PR lib/56937: printf(3) long double %a formatting is broken

Revision 1.8.42.1: download - view: text, markup, annotated - select for diffs
Mon Apr 17 18:24:52 2023 UTC (21 months, 1 week ago) by martin
Branches: netbsd-10
CVS tags: netbsd-10-0-RELEASE, netbsd-10-0-RC6, netbsd-10-0-RC5, netbsd-10-0-RC4, netbsd-10-0-RC3, netbsd-10-0-RC2, netbsd-10-0-RC1
Diff to: previous 1.8: preferred, colored
Changes since revision 1.8: +50 -1 lines
Pull up following revision(s) (requested by he in ticket #138):

	tests/lib/libc/stdio/t_printf.c: revision 1.9
	tests/lib/libc/stdio/t_printf.c: revision 1.10

Add a test for PR/57250 from Havard Eidnes

Fix the test for "inf" output, also include newline in printf format...

Revision 1.10: download - view: text, markup, annotated - select for diffs
Tue Apr 4 19:39:38 2023 UTC (21 months, 3 weeks ago) by he
Branches: MAIN
Diff to: previous 1.9: preferred, colored
Changes since revision 1.9: +2 -2 lines
Fix the test for "inf" output, also include newline in printf format...

Revision 1.9: download - view: text, markup, annotated - select for diffs
Tue Apr 4 19:30:11 2023 UTC (21 months, 3 weeks ago) by christos
Branches: MAIN
Diff to: previous 1.8: preferred, colored
Changes since revision 1.8: +50 -1 lines
Add a test for PR/57250 from Havard Eidnes

Revision 1.2.2.1: download - view: text, markup, annotated - select for diffs
Tue Apr 17 00:09:11 2012 UTC (12 years, 9 months ago) by yamt
Branches: yamt-pagecache
CVS tags: yamt-pagecache-tag8
Diff to: previous 1.2: preferred, colored; next MAIN 1.3: preferred, colored
Changes since revision 1.2: +119 -6 lines
sync with head

Revision 1.8: download - view: text, markup, annotated - select for diffs
Wed Apr 11 16:21:42 2012 UTC (12 years, 9 months ago) by jruoho
Branches: MAIN
CVS tags: yamt-pagecache-base9, yamt-pagecache-base8, yamt-pagecache-base7, yamt-pagecache-base6, yamt-pagecache-base5, yamt-pagecache-base4, tls-maxphys-base, tls-maxphys, tls-earlyentropy-base, tls-earlyentropy, riastradh-xf86-video-intel-2-7-1-pre-2-21-15, riastradh-drm2-base3, riastradh-drm2-base2, riastradh-drm2-base1, riastradh-drm2-base, riastradh-drm2, prg-localcount2-base3, prg-localcount2-base2, prg-localcount2-base1, prg-localcount2-base, prg-localcount2, phil-wifi-base, phil-wifi-20200421, phil-wifi-20200411, phil-wifi-20200406, phil-wifi-20191119, phil-wifi-20190609, phil-wifi, pgoyette-localcount-base, pgoyette-localcount-20170426, pgoyette-localcount-20170320, pgoyette-localcount-20170107, pgoyette-localcount-20161104, pgoyette-localcount-20160806, pgoyette-localcount-20160726, pgoyette-localcount, pgoyette-compat-merge-20190127, pgoyette-compat-base, pgoyette-compat-20190127, pgoyette-compat-20190118, pgoyette-compat-1226, pgoyette-compat-1126, pgoyette-compat-1020, pgoyette-compat-0930, pgoyette-compat-0906, pgoyette-compat-0728, pgoyette-compat-0625, pgoyette-compat-0521, pgoyette-compat-0502, pgoyette-compat-0422, pgoyette-compat-0415, pgoyette-compat-0407, pgoyette-compat-0330, pgoyette-compat-0322, pgoyette-compat-0315, pgoyette-compat, perseant-stdc-iso10646-base, perseant-stdc-iso10646, netbsd-9-base, netbsd-9-4-RELEASE, netbsd-9-3-RELEASE, netbsd-9-2-RELEASE, netbsd-9-1-RELEASE, netbsd-9-0-RELEASE, netbsd-9-0-RC2, netbsd-9-0-RC1, netbsd-8-base, netbsd-8-3-RELEASE, netbsd-8-2-RELEASE, netbsd-8-1-RELEASE, netbsd-8-1-RC1, netbsd-8-0-RELEASE, netbsd-8-0-RC2, netbsd-8-0-RC1, netbsd-8, netbsd-7-nhusb-base-20170116, netbsd-7-nhusb-base, netbsd-7-nhusb, netbsd-7-base, netbsd-7-2-RELEASE, netbsd-7-1-RELEASE, netbsd-7-1-RC2, netbsd-7-1-RC1, netbsd-7-1-2-RELEASE, netbsd-7-1-1-RELEASE, netbsd-7-1, netbsd-7-0-RELEASE, netbsd-7-0-RC3, netbsd-7-0-RC2, netbsd-7-0-RC1, netbsd-7-0-2-RELEASE, netbsd-7-0-1-RELEASE, netbsd-7-0, netbsd-7, netbsd-10-base, matt-nb8-mediatek-base, matt-nb8-mediatek, localcount-20160914, is-mlppp-base, is-mlppp, cjep_sun2x-base1, cjep_sun2x-base, cjep_sun2x, cjep_staticlib_x-base1, cjep_staticlib_x-base, cjep_staticlib_x, bouyer-socketcan-base1, bouyer-socketcan-base, bouyer-socketcan, agc-symver-base, agc-symver
Branch point for: netbsd-9, netbsd-10
Diff to: previous 1.7: preferred, colored
Changes since revision 1.7: +2 -2 lines
Reduce the number of snprintf(3) invocations, as sparc/qemu timeouts.

Revision 1.7: download - view: text, markup, annotated - select for diffs
Sun Mar 18 08:13:57 2012 UTC (12 years, 10 months ago) by jruoho
Branches: MAIN
Diff to: previous 1.6: preferred, colored
Changes since revision 1.6: +24 -2 lines
Verify that PR lib/22019 is no longer an issue.

Revision 1.6: download - view: text, markup, annotated - select for diffs
Sun Mar 18 07:00:51 2012 UTC (12 years, 10 months ago) by jruoho
Branches: MAIN
Diff to: previous 1.5: preferred, colored
Changes since revision 1.5: +4 -4 lines
Move the references to PRs from code comments to the test description. Once
ATF has the ability to output the metadata in the HTML reports, it should be
easy to traverse between releng and gnats -reports via links.

Revision 1.2.4.1: download - view: text, markup, annotated - select for diffs
Sat Mar 17 17:49:55 2012 UTC (12 years, 10 months ago) by bouyer
Branches: netbsd-6
CVS tags: netbsd-6-1-RELEASE, netbsd-6-1-RC4, netbsd-6-1-RC3, netbsd-6-1-RC2, netbsd-6-1-RC1, netbsd-6-1-5-RELEASE, netbsd-6-1-4-RELEASE, netbsd-6-1-3-RELEASE, netbsd-6-1-2-RELEASE, netbsd-6-1-1-RELEASE, netbsd-6-1, netbsd-6-0-RELEASE, netbsd-6-0-RC2, netbsd-6-0-RC1, netbsd-6-0-6-RELEASE, netbsd-6-0-5-RELEASE, netbsd-6-0-4-RELEASE, netbsd-6-0-3-RELEASE, netbsd-6-0-2-RELEASE, netbsd-6-0-1-RELEASE, netbsd-6-0, matt-nb6-plus-nbase, matt-nb6-plus-base, matt-nb6-plus
Diff to: previous 1.2: preferred, colored; next MAIN 1.3: preferred, colored
Changes since revision 1.2: +2 -2 lines
Pull up following revision(s) (requested by joerg in ticket #119):
	tests/lib/libc/stdio/t_printf.c: revision 1.5
	tests/lib/libc/stdio/t_scanf.c: revision 1.2
	tests/lib/libc/gen/t_humanize_number.c: revision 1.6
Mark w_printf as __printflike and fix a format string error.
Fix format strings to properly quote %.

Revision 1.5: download - view: text, markup, annotated - select for diffs
Thu Mar 15 01:44:44 2012 UTC (12 years, 10 months ago) by joerg
Branches: MAIN
Diff to: previous 1.4: preferred, colored
Changes since revision 1.4: +2 -2 lines
Fix format strings to properly quote %.

Revision 1.4: download - view: text, markup, annotated - select for diffs
Sun Feb 26 23:14:26 2012 UTC (12 years, 11 months ago) by christos
Branches: MAIN
Diff to: previous 1.3: preferred, colored
Changes since revision 1.3: +41 -2 lines
add a test to verify that snprintf float does not leak.

Revision 1.3: download - view: text, markup, annotated - select for diffs
Fri Feb 17 20:17:38 2012 UTC (12 years, 11 months ago) by christos
Branches: MAIN
Diff to: previous 1.2: preferred, colored
Changes since revision 1.2: +53 -1 lines
add positional argument tests

Revision 1.2: download - view: text, markup, annotated - select for diffs
Wed Jul 13 11:17:03 2011 UTC (13 years, 6 months ago) by jruoho
Branches: MAIN
CVS tags: yamt-pagecache-base3, yamt-pagecache-base2, yamt-pagecache-base, netbsd-6-base
Branch point for: yamt-pagecache, netbsd-6
Diff to: previous 1.1: preferred, colored
Changes since revision 1.1: +5 -5 lines
Rename few test case names. No functional change.

Revision 1.1: download - view: text, markup, annotated - select for diffs
Fri Jul 8 06:38:04 2011 UTC (13 years, 6 months ago) by jruoho
Branches: MAIN
Split out 't_printf' and 't_scanf' from 't_format' to gain the common
"functional scope" for the test files.

Diff request

This form allows you to request diffs between any two revisions of a file. You may select a symbolic revision name using the selection box or you may type in a numeric name using the type-in text box.

Log view options

CVSweb <webmaster@jp.NetBSD.org>