public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "jakub at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/114374] [12/13/14 Regression] snprintf Wformat-truncation
Date: Tue, 19 Mar 2024 11:31:30 +0000	[thread overview]
Message-ID: <bug-114374-4-l6tdqb3pLH@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-114374-4@http.gcc.gnu.org/bugzilla/>

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |aldyh at gcc dot gnu.org,
                   |                            |amacleod at redhat dot com,
                   |                            |jakub at gcc dot gnu.org

--- Comment #6 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Seems format_integer uses the ranger even at -O0, and asks the ranger there
(talking about #c5 at -O0 -Wall) for value of loop.0_1
1398          value_range vr;
1399          ptr_qry.rvals->range_of_expr (vr, arg, dir.info->callstmt);
in
  <bb 2> :
  loop_4 = 1;

  <bb 3> :
  # loop_2 = PHI <loop_4(2), loop_6(5)>
  loop.0_1 = loop_2;
  loop_6 = loop.0_1 + 1;
  __builtin_snprintf (&buf, 11, "%d", loop.0_1);
  if (loop_6 <= 9)
    goto <bb 5>; [INV]
  else
    goto <bb 4>; [INV]

  <bb 5> :
  goto <bb 3>; [100.00%]
and ranger says [irange] int [-2147483647, 9]
Haven't checked if it just for -O0 doesn't look outside of the loop or what,
not looking outside of the loop would give [-2147483648, 9] IMHO though.
Anyway, in g it is asked about old_5 in:
  <bb 2> :
  loop_3 = 1;

  <bb 3> :
  # loop_1 = PHI <loop_3(2), loop_6(5)>
  old_5 = loop_1;
  loop_6 = loop_1 + 1;
  __builtin_snprintf (&buf, 11, "%d", old_5);
  if (loop_6 <= 9)
    goto <bb 5>; [INV]
  else
    goto <bb 4>; [INV]

  <bb 5> :
  goto <bb 3>; [100.00%]
and returns [irange] int [1, 9] in that case.

  parent reply	other threads:[~2024-03-19 11:31 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-18  8:29 [Bug c/114374] New: [12/13 " torsten.mandel at sap dot com
2024-03-18  9:25 ` [Bug tree-optimization/114374] [12/13/14 " rguenth at gcc dot gnu.org
2024-03-18  9:29 ` torsten.mandel at sap dot com
2024-03-18  9:36 ` torsten.mandel at sap dot com
2024-03-18  9:37 ` torsten.mandel at sap dot com
2024-03-18 16:08 ` pinskia at gcc dot gnu.org
2024-03-19 11:31 ` jakub at gcc dot gnu.org [this message]
2024-03-19 11:45 ` jakub at gcc dot gnu.org
2024-03-22 13:30 ` law at gcc dot gnu.org

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=bug-114374-4-l6tdqb3pLH@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /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).