[prev in list] [next in list] [prev in thread] [next in thread]
List: gcc-patches
Subject: Re: backporting fix for 85602 to GCC 8
From: Franz Sirl <Franz.Sirl-kernel () lauterbach ! com>
Date: 2018-07-18 15:09:33
Message-ID: f7ed553e-4f0f-915b-406f-27ee2577f297 () lauterbach ! com
[Download RAW message or body]
Am 2018-07-18 um 01:50 schrieb Martin Sebor:
> If there are no objections I'd like to backport the solution
> for PR 85602 to avoid a class of unnecessary warnings for
> safe uses of nonstring arrays. With the release coming up
> later this week I'll go ahead and commit the patch tomorrow.
>
> https://gcc.gnu.org/viewcvs/gcc?view=revision&revision=261718
Hi Martin,
and please remember the follow-up fix
https://gcc.gnu.org/viewcvs/gcc?view=revision&revision=261751
The patch for PR 85602 makes the extended and enabled-by-Wall string
warnings (which I like!) complete. There's a warning for the majority of
cases and for the char-array-without-NUL cases there is the nonstring
attribute describing it nicely, much better than to turn off the warning
around such code.
I know that probably not too many codebases will be affected, but for
anyone affected the nonstring attribute is a much better way to avoid
the warnings than to turn it off (and if they turn off the warnings for
gcc-8 they often won't turn it on again for gcc-9+).
The nonstring attribute is also the documented way to silence the warnings.
BTW, while re-reading the documentation I noticed some minor omissions,
I attached a patch (untested). Feel free to commit it (I have no access)
if you think it's correct.
Franz.
2018-07-12 Franz Sirl <franz.sirl-kernel@lauterbach.com>
* invoke.texi (Wstringop-overflow, Wstringop-truncation):
Mention enabling via -Wall.
(Wall): Add -Wstringop-overflow02 and -Wstringop-truncation.
["stringop-doc.diff" (text/plain)]
Index: invoke.texi
===================================================================
diff --git a/trunk/gcc/doc/invoke.texi b/trunk/gcc/doc/invoke.texi
--- a/trunk/gcc/doc/invoke.texi (revision 262850)
+++ b/trunk/gcc/doc/invoke.texi (working copy)
@@ -3992,6 +3992,8 @@
-Wsizeof-pointer-memaccess @gol
-Wstrict-aliasing @gol
-Wstrict-overflow=1 @gol
+-Wstringop-overflow=2 @gol
+-Wstringop-truncation @gol
-Wswitch @gol
-Wtautological-compare @gol
-Wtrigraphs @gol
@@ -5318,7 +5320,7 @@
@}
@end smallexample
-Option @option{-Wstringop-overflow=2} is enabled by default.
+Option @option{-Wstringop-overflow=2} is enabled by @option{-Wall}.
@table @gcctabopt
@item -Wstringop-overflow
@@ -5416,6 +5418,8 @@
such arrays GCC issues warnings unless it can prove that the use is
safe. @xref{Common Variable Attributes}.
+Option @option{-Wstringop-truncation} is enabled by @option{-Wall}.
+
@item -Wsuggest-attribute=@r{[}pure@r{|}const@r{|}noreturn@r{|}format@r{|}cold@r{|}malloc@r{]}
@opindex Wsuggest-attribute=
@opindex Wno-suggest-attribute=
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic