On 04/07/18 23:00, Gerald Pfeifer wrote: > On Wed, 4 Apr 2018, Bernd Edlinger wrote: >> Is it OK for wwwdocs? > > Yes, except... > > + <li><code>-Wsizeof-pointer-div</code> warns for suspicious divisions > + of two <code>sizeof</code> expressions that divide the pointer size by > + the element size, which is the usual way to compute the array size but > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ > + won't work out correctly with pointers. > > ...this is a bit misleading. > > Dividing the pointer size by the element size is _not_ the usual way;
Yes, it is of course the _wrong_ way. This happens usually with macros that are meant to be used with arrays. > using the array size is. I am sure this is what you had in mind, just > the wording is a bit unfortunate. Perhaps "...which looks like the > usual way..." and "the size of a pointer" and "the size of elements > it points to"? And the sizeof expressions do not actually divide > anything.) > > I seem to have a writer's block right now, or I would have proposed > a full alternative, but hope the above gives you an indication? > > > Definitely okay to commit the other parts of this patch, and let's > just work on this item a bit more. > Thanks for your review! I committed the other parts and rewrote this one along your suggested wording. See attached patch. Is it OK? Bernd.
Index: htdocs/gcc-8/changes.html =================================================================== RCS file: /cvs/gcc/wwwdocs/htdocs/gcc-8/changes.html,v retrieving revision 1.56 diff -u -r1.56 changes.html --- htdocs/gcc-8/changes.html 7 Apr 2018 21:15:39 -0000 1.56 +++ htdocs/gcc-8/changes.html 7 Apr 2018 21:24:14 -0000 @@ -287,6 +287,13 @@ by <code>-Wextra</code>.</li> </ul> <ul> + <li><code>-Wsizeof-pointer-div</code> warns for suspicious divisions + of the size of a pointer and the size of the element it points to, + which looks like the usual way to compute the array size but + won't work out correctly with pointers. + This warning is enabled by <code>-Wall</code>.</li> + </ul> + <ul> <li><code>-Wcast-align=strict</code> warns whenever a pointer is cast such that the required alignment of the target is increased. For example, warn if a <code>char *</code> is cast to an <code>int *</code>