Re: [PATCH V2] sparse: Allow override of sizeof(bool) warning

Joe Perches
2014-02-27T03:38:52Z

(adding Ben Pfaff and Christopher Li)

On Wed, 2014-02-26 at 19:29 -0800, H. Peter Anvin wrote:
> On 02/26/2014 06:58 PM, Josh Triplett wrote:
> > On Wed, Feb 26, 2014 at 06:53:14PM -0800, Joe Perches wrote:
> >> Allow an override to emit or not the sizeof(bool) warning
> >> Add a description to the manpage.
> >>
> >> Signed-off-by: Joe Perches <joe@perches.com>
> >
> > Reviewed-by: Josh Triplett <josh@joshtriplett.org>
> >
>
> I have to admit that this particular warning is a bit odd to me. I'm
> wondering what kind of bugs it was intended to catch.
>
> In particular, things that incorrectly assumes the size of bool to be
> anything in particular would seem unlikely to actually use sizeof().

Dunno, the commit log for the commit that added it doesn't quite
match the code and is seemingly unaware that the c99 spec doesn't
specify sizeof(bool).

Ben Pfaff <blp@nicira.com>
Date: Wed May 4 16:39:54 2011 -0700

evaluate: Allow sizeof(_Bool) to succeed.

Without this commit, sizeof(_Bool) provokes an error with "cannot size
expression" because _Bool is a 1-bit type and thus not a multiple of a full
byte in size. But sizeof(_Bool) is valid C that should evaluate to 1, so
this commit fixes the problem and adds a regression test.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Signed-off-by: Christopher Li <sparse@chrisli.org>