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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakub at gcc dot gnu.org

--- Comment #10 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
(In reply to Martin Sebor from comment #6)
> 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];

I'm happy you've removed the static, because it performs a runtime construction
of the array.  But: 1) the comment is now wrong 2) it is really weird and
inefficient way of writing:
  if (width == INT_MIN)
    res.range.max = HOST_WIDE_INT_MAX;
  else
    res.range.max = format_floating_max (ldbl ? long_double_type_node
                                         : double_type_node, 'f', prec);

> @@ -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];

Similarly.

Reply via email to