https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114746

            Bug ID: 114746
           Summary: With FLT_EVAL_METHOD = 2, -fexcess-precision=fast
                    reduces the precision of floating-point constants
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: vincent-gcc at vinc17 dot net
  Target Milestone: ---

-fexcess-precision was added to resolve bug 323, so that with
-fexcess-precision=standard, after an assignment or a cast, the value is
converted to its semantic type; this conversion makes the program slower, hence
-fexcess-precision=fast to have faster programs *without sacrificing their
accuracy* in average (except for programs that are based on such a conversion).
Said otherwise, the values may be kept with more precision than normally
expected.

Thus it is not expected that -fexcess-precision=fast reduces the precision of a
value.

However, with FLT_EVAL_METHOD = 2, -fexcess-precision=fast reduces the
precision of floating-point constants compared to what is specified by the
standard. This is a much worse issue.

Testcase:

#include <stdio.h>
#include <float.h>

int main (void)
{
  printf ("FLT_EVAL_METHOD = %d\n", FLT_EVAL_METHOD);
  printf ("%La\n%La\n", 1e-8L, (long double) 1e-8);
  printf ("%a\n%a\n", (double) 1e-8, (double) 1e-8f);
  return 0;
}

With GCC 14.0.1 20240330 (experimental) [master r14-9728-g6fc84f680d0] using
-m32 -fexcess-precision=fast, I get:

FLT_EVAL_METHOD = 2
0xa.bcc77118461cefdp-30
0xa.bcc77118461dp-30
0x1.5798ee2308c3ap-27
0x1.5798eep-27

instead of the expected output (e.g. by using -fexcess-precision=standard)

FLT_EVAL_METHOD = 2
0xa.bcc77118461cefdp-30
0xa.bcc77118461cefdp-30
0x1.5798ee2308c3ap-27
0x1.5798ee2308c3ap-27

Reply via email to