From: Xi Ruoyao <ryxi@stu.xidian.edu.cn>
To: gcc-patches@gcc.gnu.org
Cc: ryxi@stu.xidian.edu.cn
Subject: [PATCH 6/6] New warnings -Wstring-plus-{char, int} (PR c++/62181)
Date: Mon, 12 Jun 2017 01:39:00 -0000 [thread overview]
Message-ID: <1497231597.27153.16.camel@stu.xidian.edu.cn> (raw)
In-Reply-To: <1497230800.27153.4.camel@stu.xidian.edu.cn>
[-- Attachment #1: Type: text/plain, Size: 448 bytes --]
This patch adds document of -Wstring-plus-int and -Wstring-plus-char.
gcc/ChangeLog:
2017-06-12  Xi Ruoyao  <ryxi@stu.xidian.edu.cn>
* doc/invoke.texi (Warning Options): Document -Wstring-plus-int
and -Wstring-plus-char.
---
 gcc/doc/invoke.texi | 22 +++++++++++++++++++++-
 1 file changed, 21 insertions(+), 1 deletion(-)
--
Xi Ruoyao <ryxi@stu.xidian.edu.cn>
School of Aerospace Science and Technology, Xidian University
[-- Attachment #2: 0006-Document-new-warning-options.patch --]
[-- Type: text/x-patch, Size: 1709 bytes --]
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index 5d41649..4859341 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -311,7 +311,7 @@ Objective-C and Objective-C++ Dialects}.
-Wsizeof-pointer-memaccess -Wsizeof-array-argument @gol
-Wstack-protector -Wstack-usage=@var{len} -Wstrict-aliasing @gol
-Wstrict-aliasing=n -Wstrict-overflow -Wstrict-overflow=@var{n} @gol
--Wstringop-overflow=@var{n} @gol
+-Wstringop-overflow=@var{n} @gol -Wstring-plus-char -Wstring-plus-int
-Wsuggest-attribute=@r{[}pure@r{|}const@r{|}noreturn@r{|}format@r{]} @gol
-Wsuggest-final-types @gol -Wsuggest-final-methods -Wsuggest-override @gol
-Wmissing-format-attribute -Wsubobject-linkage @gol
@@ -5125,6 +5125,26 @@ whether to issue a warning. Similarly to @option{-Wstringop-overflow=3} this
setting of the option may result in warnings for benign code.
@end table
+@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.
+
+@smallexample
+const char *p = "abc", *q;
+q = p + 'a';
+@end smallexample
+
+@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}.
+
@item -Wsuggest-attribute=@r{[}pure@r{|}const@r{|}noreturn@r{|}format@r{]}
@opindex Wsuggest-attribute=
@opindex Wno-suggest-attribute=
--
2.7.1
next prev parent reply other threads:[~2017-06-12 1:39 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 5/6] " Xi Ruoyao
2017-06-12 1:39 ` Xi Ruoyao [this message]
2017-06-19 16:57 ` [PATCH 6/6] " Martin Sebor
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=1497231597.27153.16.camel@stu.xidian.edu.cn \
--to=ryxi@stu.xidian.edu.cn \
--cc=gcc-patches@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).