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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2016-09-21
                 CC|                            |jakub at gcc dot gnu.org,
                   |                            |msebor at gcc dot gnu.org
     Ever confirmed|0                           |1

--- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
This looks like a major flaw in the gimple-ssa-sprintf.c stuff.
In particular, -W* options should not affect code generationm but the file is
full of conditionals on warn_format_length value.  I think the only way out of
this is to separate the warning handling from the flag_printf_return_value
handling, it can be done by the same functions, but it should differentiate
between warning (then emit warnings, but don't change anything, honor
warn_format_length, ignore flag_printf_return_value), and code changes (in that
case it shouldn't emit warnings, it should ignore warn_format_length, honor
flag_printf_return_value).
I suppose easiest would be to add some boolean into format_result, and:
  if (warn_format_length)
    {
      format_result res = format_result (false);
      compute_format_length (info, &res);
    }

  if (flag_printf_return_value && optimize > 0)
    {
      format_result res = format_result (true);
      compute_format_length (info, &res);
      if (!flag_rounding_math || !res.floating)
        try_substitute_return_value (gsi, info, res);
    }

Reply via email to