On 07/18/2018 09:09 AM, Franz Sirl wrote:
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
I've committed the 85602 changes to 8-branch. I also updated
the manual to mention that -Wstringop-truncation is enabled by
-Wall (thanks). The rest seems out of scope so I'll look into
it for trunk.
Martin
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-ker...@lauterbach.com>
* invoke.texi (Wstringop-overflow, Wstringop-truncation):
Mention enabling via -Wall.
(Wall): Add -Wstringop-overflow02 and -Wstringop-truncation.