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

--- Comment #6 from Martin Sebor <msebor at gcc dot gnu.org> ---
The bug behind the wrong output in comment #0 is in the format_floating
function with an unknown argument failing to use the precision.  The following
simple patch fixes that.

@@ -1261,9 +1277,9 @@ format_floating (const conversion_spec &spec, int
        res.range.min = 2 + (prec < 0 ? 6 : prec);

        /* Compute the maximum just once.  */
-       static const int f_max[] = {
-         format_floating_max (double_type_node, 'f'),
-         format_floating_max (long_double_type_node, 'f')
+       const int f_max[] = {
+         format_floating_max (double_type_node, 'f', prec),
+         format_floating_max (long_double_type_node, 'f', prec)
        };
        res.range.max = width == INT_MIN ? HOST_WIDE_INT_MAX : f_max [ldbl];

@@ -1279,9 +1295,9 @@ format_floating (const conversion_spec &spec, int
        res.range.min = 2 + (prec < 0 ? 6 : prec);

        /* Compute the maximum just once.  */
-       static const int g_max[] = {
-         format_floating_max (double_type_node, 'g'),
-         format_floating_max (long_double_type_node, 'g')
+       const int g_max[] = {
+         format_floating_max (double_type_node, 'g', prec),
+         format_floating_max (long_double_type_node, 'g', prec)
        };
        res.range.max = width == INT_MIN ? HOST_WIDE_INT_MAX : g_max [ldbl];

Reply via email to