Attached is the documentation update for Jakub's recent change
to recognize a cast to void* as a suppression mechanism for
-Wclass-memaccess (the last sentence).

I also reworded the cumbersome first sentence a bit so the diff
looks bigger than the substantive change itself actually is.

Martin
gcc/ChangeLog:

	* doc/invoke.texi (-Wlass-memaccess): Document suppression by casting.

Index: gcc/doc/invoke.texi
===================================================================
--- gcc/doc/invoke.texi	(revision 256650)
+++ gcc/doc/invoke.texi	(working copy)
@@ -2954,20 +2954,22 @@ C++17 it calls @code{f<void(*)()noexcept>}.
 @item -Wclass-memaccess @r{(C++ and Objective-C++ only)}
 @opindex Wclass-memaccess
 Warn when the destination of a call to a raw memory function such as
-@code{memset} or @code{memcpy} is an object of class type writing into which
-might bypass the class non-trivial or deleted constructor or copy assignment,
-violate const-correctness or encapsulation, or corrupt the virtual table.
-Modifying the representation of such objects may violate invariants maintained
-by member functions of the class.  For example, the call to @code{memset}
-below is undefined because it modifies a non-trivial class object and is,
-therefore, diagnosed.  The safe way to either initialize or clear the storage
-of objects of such types is by using the appropriate constructor or assignment
-operator, if one is available.
+@code{memset} or @code{memcpy} is an object of class type, and when writing
+into such an object might bypass the class non-trivial or deleted constructor
+or copy assignment, violate const-correctness or encapsulation, or corrupt
+the virtual table.  Modifying the representation of such objects may violate
+invariants maintained by member functions of the class.  For example, the call
+to @code{memset} below is undefined because it modifies a non-trivial class
+object and is, therefore, diagnosed.  The safe way to either initialize or
+clear the storage of objects of such types is by using the appropriate
+constructor or assignment operator, if one is available.
 @smallexample
 std::string str = "abc";
-memset (&str, 0, 3);
+memset (&str, 0, sizeof str);
 @end smallexample
-The @option{-Wclass-memaccess} option is enabled by @option{-Wall}.
+The @option{-Wclass-memaccess} option is enabled by @option{-Wall}.  Casting
+the pointer to the class object to @code{void *} or to a type that can be
+safely accessed by the raw memory function suppresses the warning.
 
 @item -Wnon-virtual-dtor @r{(C++ and Objective-C++ only)}
 @opindex Wnon-virtual-dtor

Reply via email to