public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "ishikawa at yk dot rim.or.jp" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/94021] -Wformat-truncation false positive due to excessive integer range
Date: Fri, 14 Apr 2023 05:48:23 +0000	[thread overview]
Message-ID: <bug-94021-4-HeatpXEsch@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-94021-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #10 from ishikawa,chiaki <ishikawa at yk dot rim.or.jp> ---
It would be great if the problem is fixed in later versions.
I observe the error with gcc-12 on my computer yet.

*BUT* compiling with -O instead of -O2 succeeds !?

gcc-12 version.

gcc-12 (Debian 12.2.0-14) 12.2.0
Copyright (C) 2022 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

No error with -O !?

ishikawa@ip030:/NREF-COMM-CENTRAL/mozilla$ gcc-12 -c -O -Wall /tmp/pr94021.c

Error with -O2 as before.

ishikawa@ip030:/NREF-COMM-CENTRAL/mozilla$ gcc-12 -c -O2 -Wall /tmp/pr94021.c
/tmp/pr94021.c: In function ‘format_utc_offset’:
/tmp/pr94021.c:14:45: warning: ‘%02i’ directive output may be truncated writing
2 bytes into a region of size between 1 and 5 [-Wformat-truncation=]
   14 |     __builtin_snprintf (a, sizeof a, "%s%02i%02i", "+", h, m);
      |                                             ^~~~
/tmp/pr94021.c:14:38: note: directive argument in the range [0, 59]
   14 |     __builtin_snprintf (a, sizeof a, "%s%02i%02i", "+", h, m);
      |                                      ^~~~~~~~~~~~
/tmp/pr94021.c:14:5: note: ‘__builtin_snprintf’ output between 6 and 10 bytes
into a destination of size 8
   14 |     __builtin_snprintf (a, sizeof a, "%s%02i%02i", "+", h, m);
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ishikawa@ip030:/NREF-COMM-CENTRAL/mozilla$

  parent reply	other threads:[~2023-04-14  5:48 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <bug-94021-4@http.gcc.gnu.org/bugzilla/>
2020-12-17 17:14 ` msebor at gcc dot gnu.org
2021-01-04 15:34 ` amacleod at redhat dot com
2023-04-14  5:48 ` ishikawa at yk dot rim.or.jp [this message]
2023-06-21  4:33 ` pinskia 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-94021-4-HeatpXEsch@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).