1 /* Beginning of modification history */
2 /* Written 02-04-10 by Paul Green (Paul.Green@stratus.com) */
3 /* End of modification history */
5 /* This test case is extracted from Perl version 5.7.3. It is
6 in the Perl_unpack_str function of the pp_pack.c source file.
8 GCC 2.95.2 improperly assumes that it can compensate for an
9 extra fsub by performing a fadd. This would work in
10 fixed-point arithmetic, but does not work in floating-point
13 This problem has been seen on HP-UX and on Stratus VOS, both
14 of which have an HP PA-RISC target (hppa1.1). The Stratus
15 bug number is gnu_g++-220. */
17 /* #define _POSIX_C_SOURCE 199506L -- added by Configure */
22 void test(double *result)
29 const int bits_in_uv = 8 * sizeof(cuv);
35 if (checksum > bits_in_uv) {
38 adouble = (double) (1 << (checksum & 15));
40 while (checksum >= 16) {
45 /* At -O1, GCC 2.95.2 compiles the following loop
52 fadd,dbl %fr4,%fr12,%fr4
53 fsub,dbl %fr4,%fr12,%fr4
55 This code depends on the floading-add and
56 floating-subtract retaining all of the
57 precision present in the operands. There is
58 no such guarantee when using floating-point,
59 as this test case demonstrates.
61 The code is okay at -O0. */
66 cdouble = modf (cdouble / adouble, &trouble) * adouble;
73 int main (int argc, char ** argv)
79 if (argc == 2 && !strcmp(argv[1],"-v"))
80 printf ("value = %.18e\n", value);
82 if (value != 9.007199254740991e+15) {
83 printf ("t001 fails!\n");
87 printf ("t001 works.\n");