From: Martin Sebor <msebor@gmail.com>
To: Xi Ruoyao <ryxi@stu.xidian.edu.cn>, gcc-patches@gcc.gnu.org
Subject: Re: [PATCH 6/6] New warnings -Wstring-plus-{char, int} (PR c++/62181)
Date: Mon, 19 Jun 2017 16:57:00 -0000 [thread overview]
Message-ID: <781c46ec-12b3-a1bc-e320-5204f82b463b@gmail.com> (raw)
In-Reply-To: <1497231597.27153.16.camel@stu.xidian.edu.cn>
On 06/11/2017 07:39 PM, Xi Ruoyao wrote:
> This patch adds document of -Wstring-plus-int and -Wstring-plus-char.
+@item -Wstring-plus-char
+@opindex Wstring-plus-char
+@opindex Wno-string-plus-char
+Warn for adding a character to a string pointer, which seems like a failed
+attempt to append to the string. For example, this option will issue a
+warning for the code below.
The text above should be corrected for grammar:
Warn when a character is added to a character pointer. Such
addition it may be an incorrect attempt to append the character
to a string.
Similarly, the text below should be corrected (though as I mentioned
in my earlier response to one of the prior patches, I would prefer
to see the out-of-bounds warning(s) phrased in terms the (undefined)
effects of the addition and included in -Warray-bounds rather than
adding a new option based on assumptions about the intended effects,
and extended to all arrays of known bound rather than applied only
to string literals).
+@item -Wstring-plus-int
+@opindex Wstring-plus-int
+@opindex Wno-string-plus-int
+Warn for adding an integer to a string literal, which may forms a pointer
+out of the bound of the string. The typical examples this warns about are
+@samp{"abc" + 'd'}, @samp{"abc" + getchar()} and @samp{"abc" + 5}, but
+not @samp{"abc" + 1}.
Warn when an integer constant in excess of its upper bound is
added to a string literal.
Martin
next prev parent reply other threads:[~2017-06-19 16:57 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-12 1:26 [PATCH 0/6] " Xi Ruoyao
2017-06-12 1:31 ` [PATCH 1/6] " Xi Ruoyao
2017-06-12 1:32 ` [PATCH 2/6] " Xi Ruoyao
2017-06-19 16:51 ` Martin Sebor
2017-06-19 17:28 ` Xi Ruoyao
2017-06-19 18:44 ` Martin Sebor
2017-06-19 19:36 ` Xi Ruoyao
2017-06-22 10:26 ` Xi Ruoyao
2017-07-15 16:33 ` Gerald Pfeifer
2017-06-12 1:34 ` [PATCH 3/6] " Xi Ruoyao
2017-06-19 16:30 ` Martin Sebor
2017-06-19 17:35 ` Xi Ruoyao
2017-06-12 1:36 ` [PATCH 4/6] " Xi Ruoyao
2017-06-12 1:39 ` [PATCH 6/6] " Xi Ruoyao
2017-06-19 16:57 ` Martin Sebor [this message]
2017-06-12 1:39 ` [PATCH 5/6] " Xi Ruoyao
2017-06-19 12:43 ` [PING PATCH 0/6] " Xi Ruoyao
2017-06-19 16:20 ` [PATCH " Martin Sebor
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=781c46ec-12b3-a1bc-e320-5204f82b463b@gmail.com \
--to=msebor@gmail.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=ryxi@stu.xidian.edu.cn \
/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).