public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Martin Sebor <msebor@gmail.com>
To: Richard Biener <richard.guenther@gmail.com>
Cc: Gcc Patch List <gcc-patches@gcc.gnu.org>
Subject: Re: enable -Wformat-truncation with -Og (PR 79691)
Date: Fri, 24 Feb 2017 18:20:00 -0000	[thread overview]
Message-ID: <d836836d-89a0-c6fa-a5f8-cbfa56d040ea@gmail.com> (raw)
In-Reply-To: <CAFiYyc0gWCJPczDWMpgJ5vT9ZCkHVq5h=mu59A7oUe+DE0Vm4A@mail.gmail.com>

On 02/24/2017 03:10 AM, Richard Biener wrote:
> On Fri, Feb 24, 2017 at 1:35 AM, Martin Sebor <msebor@gmail.com> wrote:
>> Bug 79691 - -Wformat-truncation suppressed by (and only by) -Og
>> points out that the gimple-ssa-sprintf pass doesn't run when
>> this optimization option is used.  That's because I forgot to
>> add it to the set of optimization passes that run with that
>> option.  The attached trivial patch tested on x86_64 corrects
>> the oversight.
>>
>> Is this okay for 7.0?
>
> Any reason for the placement before copy-prop?  I'd have done it
> after pass_late_warn_uninitialized for example.

I wanted to make sure that folded sprintf return values would be
eligible for further copy propagation.  E.g., that a + b would
be folded into a constant:

   int foo (void)
   {
     int a = snprintf (0, 0, "%i", 123);
     int b = snprintf (0, 0, "%i", 1234);
     return a + b;
   }

But I could have easily missed some important use case where this
placement will compromise the warning.  I don't have any tests
for this one way or the other so I'm happy to go with your
recommendation.  Let me know which you think is more appropriate
(if you have a suggestion for a test case I'd be grateful).

>
> Also doesn't pass_sprintf_length rely on get_range_info ()?  With -Og
> nothing populates those so you'll always get effectively VARYING ranges.

It does when it's available but as Jakub noted, it works without
it as well (at -O0).

Thanks
Martin

  parent reply	other threads:[~2017-02-24 17:51 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-24  5:07 Martin Sebor
2017-02-24 10:14 ` Richard Biener
2017-02-24 10:22   ` Jakub Jelinek
2017-02-24 18:20   ` Martin Sebor [this message]
2017-02-27  8:49     ` Richard Biener

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=d836836d-89a0-c6fa-a5f8-cbfa56d040ea@gmail.com \
    --to=msebor@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=richard.guenther@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).