public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "msebor at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c/97817] -Wformat-truncation=2 elicits invalid warning
Date: Fri, 13 Nov 2020 22:36:26 +0000	[thread overview]
Message-ID: <bug-97817-4-rA5AJAtEHW@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-97817-4@http.gcc.gnu.org/bugzilla/>

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

Martin Sebor <msebor at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |msebor at gcc dot gnu.org
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |INVALID

--- Comment #3 from Martin Sebor <msebor at gcc dot gnu.org> ---
Level 2 of the warning is documented to warn also about calls to bounded
functions whose return value is used and that might result in truncation given
an argument of sufficient length or magnitude.  The level is meant to help
write code with the least likelihood of truncation given unknown arguments.

In the test case, the output of the function will be truncated unless buflen is
at least 16.  It will also be truncated if buflen is 16 and errnum is either
negative or bigger than 9.  The note printed after the warning indicates the
minimum size of output (i.e., 16) and the maximum (26) beyond which truncation
is impossible.

  parent reply	other threads:[~2020-11-13 22:36 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-13 18:16 [Bug c/97817] New: " jim at meyering dot net
2020-11-13 18:24 ` [Bug c/97817] " jim at meyering dot net
2020-11-13 18:37 ` schwab@linux-m68k.org
2020-11-13 22:36 ` msebor at gcc dot gnu.org [this message]
2020-11-13 23:03 ` jim at meyering dot net
2020-11-18 23:16 ` msebor 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-97817-4-rA5AJAtEHW@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).