Patrick Palka 70aa0e6eef libstdc++: Robustify long double std::to_chars testcase [PR98384]
The long double std::to_chars testcase currently verifies the
correctness of its output by comparing it to that of printf, so if
there's a mismatch between to_chars and printf, the test FAILs.  This
works well for the scientific, fixed and general formatting modes,
because the corresponding printf conversion specifiers (%e, %f and %g)
are rigidly specified.

But this doesn't work well for the hex formatting mode because the
corresponding printf conversion specifier %a is more flexibly specified.
For instance, the hexadecimal forms 0x1p+0, 0x2p-1, 0x4p-2 and 0x8p-3
are all equivalent and valid outputs of the %a specifier for the number 1.
The apparent freedom here is the choice of leading hex digit -- the
standard just requires that the leading hex digit is nonzero for
normalized numbers.

Currently, our hexadecimal formatting implementation uses 0/1/2 as the
leading hex digit for floating point types that have an implicit leading
mantissa bit which in practice means all supported floating point types
except x86 long double.  The latter type has a 64 bit mantissa with an
explicit leading mantissa bit, and for this type our implementation uses
the most significant four bits of the mantissa as leading hex digit.
This seems to be consistent with most printf implementations, but not
all, as PR98384 illustrates.

In order to avoid false-positive FAILs due to arbitrary disagreement
between to_chars and printf about the choice of leading hex digit, this
patch makes the testcase's verification via printf conditional on the
leading hex digits first agreeing.  An additional verification step is
also added: round-tripping the output of to_chars through from_chars
should recover the value exactly.

libstdc++-v3/ChangeLog:

	PR libstdc++/98384
	* testsuite/20_util/to_chars/long_double.cc: Include <optional>.
	(test01): Simplify verifying the nearby values by using a
	2-iteration loop and a dedicated output buffer to check that the
	nearby values are different.  Factor out the printf-based
	verification into a local function, and check that the leading
	hex digits agree before comparing to the output of printf.  Also
	verify the output by round-tripping it through from_chars.
2021-02-24 12:24:43 -05:00
2021-01-06 00:16:55 +00:00
2021-01-06 00:16:55 +00:00
2021-02-09 00:16:30 +00:00
2020-12-15 00:16:35 +00:00
2021-02-03 00:16:23 +00:00
2021-01-17 00:16:23 +00:00
2021-01-04 10:26:59 +01:00
2021-01-16 00:16:29 +00:00
2021-02-13 00:16:38 +00:00
2021-01-06 00:16:55 +00:00
2021-01-13 00:16:36 +00:00
2021-01-04 10:26:59 +01:00
2021-01-06 00:16:55 +00:00
2021-02-13 00:16:38 +00:00
2021-02-19 12:33:25 -08:00
2021-02-23 00:16:34 +00:00
2021-01-06 00:16:55 +00:00
2021-02-21 00:16:18 +00:00
2021-01-16 00:16:29 +00:00
2021-01-06 00:16:55 +00:00
2021-01-06 00:16:55 +00:00
2021-02-05 00:16:23 +00:00
2021-01-06 00:16:55 +00:00
2021-01-06 00:16:55 +00:00
2021-01-06 00:16:55 +00:00
2021-01-06 00:16:55 +00:00
2020-12-17 00:16:37 +00:00
2021-01-06 00:16:55 +00:00
2020-01-15 14:29:53 +01:00
2020-12-02 11:04:01 -07:00
2021-02-24 00:16:26 +00:00
2020-12-15 07:42:59 -08:00
2020-12-15 07:42:59 -08:00
2021-01-05 16:04:14 -07:00
2020-12-15 07:42:59 -08:00

This directory contains the GNU Compiler Collection (GCC).

The GNU Compiler Collection is free software.  See the files whose
names start with COPYING for copying permission.  The manuals, and
some of the runtime libraries, are under different terms; see the
individual source files for details.

The directory INSTALL contains copies of the installation information
as HTML and plain text.  The source of this information is
gcc/doc/install.texi.  The installation information includes details
of what is included in the GCC sources and what files GCC installs.

See the file gcc/doc/gcc.texi (together with other files that it
includes) for usage and porting information.  An online readable
version of the manual is in the files gcc/doc/gcc.info*.

See http://gcc.gnu.org/bugs/ for how to report bugs usefully.

Copyright years on GCC source files may be listed using range
notation, e.g., 1987-2012, indicating that every year in the range,
inclusive, is a copyrightable year that could otherwise be listed
individually.
Description
No description provided
Readme 3.1 GiB
Languages
C 48%
Ada 18.3%
C++ 14.1%
Go 7%
GCC Machine Description 4.6%
Other 7.7%