This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] enhance documentation of -Wstringop-truncation


It was suggested to me that it might be helpful to mention
attribute nonstring as a solution to -Wstringop-truncation
warnings.  I think it's a good idea to add a reference to
the attribute to the manual.  The attached patch does that.

Since the attribute is suitable only under rare conditions
suggesting it in the text of the diagnostics (e.g., in the
form of a note) would unlikely be useful (and, if acted on,
could even lead to other kinds of warnings) so I opted not
to make such a change.

Martin
2017-12-03  Martin Sebor  <msebor@redhat.com>

	* doc/invoke.texi (-Wstringop-truncation): Mention attribute nonstring.

Index: gcc/doc/invoke.texi
===================================================================
--- gcc/doc/invoke.texi	(revision 255369)
+++ gcc/doc/invoke.texi	(working copy)
@@ -5256,6 +5256,14 @@ void copy (const char *s)
 @}
 @end smallexample
 
+In situations where a character array is intended to store a sequence
+of bytes with no terminating @code{NUL} such an array may be annotated
+with attribute @code{nonstring} to avoid this warning.  Such arrays,
+however, are not suitable arguments to functions that expect
+@code{NUL}-terminated strings.  To help detect accidental misuses of
+such arrays, GCC issues warnings unless it can prove that the use is
+safe.  @xref{Common Variable Attributes}.
+
 @item -Wsuggest-attribute=@r{[}pure@r{|}const@r{|}noreturn@r{|}format@r{|}cold@r{|}malloc@r{]}
 @opindex Wsuggest-attribute=
 @opindex Wno-suggest-attribute=

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]