lkml.org 
[lkml]   [2018]   [Apr]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v2] add -Wpointer-arith sparse flag to toggle sizeof(void) warnings
On Sun, Apr 08, 2018 at 09:48:24AM +0200, Luc Van Oostenryck wrote:
> With the warning disabled by default (for the moment), I had to adapt
> the testsuite with:

Ah, so should I include that change in the patch itself when I make a V3?

> > +Warn about anything that depends on the \fBsizeof\fR a function type or of void.
>
> Maybe it would be useful to add something along the line of "like directly using
> the sizeof operator on void or doing pointer arithmetic on a void pointer" ?

I actually just took the explanation straight from the GCC man page
since I figured the explanation should match (as the flag itself is
basicallt copied).

But I do sort of like your wording of it more, so if no one else sees
any reasons to _not_ to diverge from GCC's wording here I have no problem
changing that.

> > +Although non-standard (and somewhat illogical), constructs such as \fBsizeof(void)\fR
> > +are often useful when the intent is to operate on an expression without evaluating
> > +it, e.g. in the following integer constant expression predicate:
> > +.nf
> > +#define __is_constexpr(x) \\
> > + (sizeof(int) == sizeof(*(8 ? ((void *)((long)(x) * 0l)) : (int *)8)))
> > +.fi
>
> I think that pointer arithmetic is much more useful than taking the size of void
> (being able to take the size of *any* thing is somewhere in the middle, IMO).
> But in all case, I don't think this part should belong to the man page.

Also have no problem eliding this section if no one else has any
good arguments for keeping it.

--
Cheers,
Joey Pabalinas
[unhandled content-type:application/pgp-signature]
\
 
 \ /
  Last update: 2018-04-10 00:52    [W:0.052 / U:0.348 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site