* New and bogus(!) warning produced by sparse.
@ 2005-09-30 14:03 Anton Altaparmakov
2005-09-30 14:29 ` Linus Torvalds
0 siblings, 1 reply; 5+ messages in thread
From: Anton Altaparmakov @ 2005-09-30 14:03 UTC (permalink / raw)
To: Linus Torvalds; +Cc: linux-kernel
Hi Linus,
I just did a git pull on sparse and it produced a new and I believe
bogus warning when trying to assign a value to a bit field member. The
warning is:
warning: generating address of non-lvalue (1)
Below is an example program that triggers the warning when you run:
sparse sparse-test.c
Best regards,
Anton
--
Anton Altaparmakov <aia21 at cam.ac.uk> (replace at with @)
Unix Support, Computing Service, University of Cambridge, CB2 3QH, UK
Linux NTFS maintainer / IRC: #ntfs on irc.freenode.net
WWW: http://linux-ntfs.sf.net/ & http://www-stu.christs.cam.ac.uk/~aia21/
--- sparse-test.c ---
int main(void)
{
struct {
unsigned bit1:1;
unsigned bit2:1;
} bits = { 0, 0 };
bits.bit1 = 1; /* sparse warns here! */
bits.bit2 = 0; /* sparse warns here! */
return 0;
}
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: New and bogus(!) warning produced by sparse.
2005-09-30 14:03 New and bogus(!) warning produced by sparse Anton Altaparmakov
@ 2005-09-30 14:29 ` Linus Torvalds
2005-09-30 14:34 ` Linus Torvalds
2005-09-30 15:37 ` Linus Torvalds
0 siblings, 2 replies; 5+ messages in thread
From: Linus Torvalds @ 2005-09-30 14:29 UTC (permalink / raw)
To: Anton Altaparmakov; +Cc: linux-kernel
On Fri, 30 Sep 2005, Anton Altaparmakov wrote:
>
> I just did a git pull on sparse and it produced a new and I believe
> bogus warning when trying to assign a value to a bit field member. The
> warning is:
Thanks, that's indeed very bogus.
I see why it happens, will fix sparse momentarily (btw, for sparse bugs,
use "linux-sparse@vger.kernel.org" rather than LKML - since this is
clearly not a kernel problem ;)
Linus
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: New and bogus(!) warning produced by sparse.
2005-09-30 14:29 ` Linus Torvalds
@ 2005-09-30 14:34 ` Linus Torvalds
2005-09-30 15:37 ` Linus Torvalds
1 sibling, 0 replies; 5+ messages in thread
From: Linus Torvalds @ 2005-09-30 14:34 UTC (permalink / raw)
To: Anton Altaparmakov; +Cc: linux-kernel
On Fri, 30 Sep 2005, Linus Torvalds wrote:
>
> I see why it happens, will fix sparse momentarily (btw, for sparse bugs,
> use "linux-sparse@vger.kernel.org" rather than LKML - since this is
> clearly not a kernel problem ;)
Side note: it has nothing to do with bit-fields: it happens for any
structure member that sparse will have incorrectly figured out as having a
value pre-assigned to it. So even
struct {
int value;
} dummy = { 0 };
dummy.value = 1;
will generate the warning. It isn't that a bitfield cannot have it's
address taken, it's that sparse has incorrectly "optimized" dummy.value to
be 0, so it ends up evaluating it as
0 = 1;
and says that it's trying to assign a non-lvalue.. Very stupid.
Linus
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: New and bogus(!) warning produced by sparse.
2005-09-30 14:29 ` Linus Torvalds
2005-09-30 14:34 ` Linus Torvalds
@ 2005-09-30 15:37 ` Linus Torvalds
2005-09-30 15:48 ` Anton Altaparmakov
1 sibling, 1 reply; 5+ messages in thread
From: Linus Torvalds @ 2005-09-30 15:37 UTC (permalink / raw)
To: Anton Altaparmakov; +Cc: linux-kernel
On Fri, 30 Sep 2005, Linus Torvalds wrote:
>
> I see why it happens, will fix sparse momentarily
Fixed, pushed out.
Linus
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: New and bogus(!) warning produced by sparse.
2005-09-30 15:37 ` Linus Torvalds
@ 2005-09-30 15:48 ` Anton Altaparmakov
0 siblings, 0 replies; 5+ messages in thread
From: Anton Altaparmakov @ 2005-09-30 15:48 UTC (permalink / raw)
To: Linus Torvalds; +Cc: linux-kernel
On Fri, 2005-09-30 at 08:37 -0700, Linus Torvalds wrote:
>
> On Fri, 30 Sep 2005, Linus Torvalds wrote:
> >
> > I see why it happens, will fix sparse momentarily
>
> Fixed, pushed out.
Pulled, compiled and warning is gone. Thanks!
And sorry I sent it to lkml, I had forgotten about linux-sparse ml and
it started out as a kernel related email given I saw it when compiling
kernel source. (-;
Best regards,
Anton
--
Anton Altaparmakov <aia21 at cam.ac.uk> (replace at with @)
Unix Support, Computing Service, University of Cambridge, CB2 3QH, UK
Linux NTFS maintainer / IRC: #ntfs on irc.freenode.net
WWW: http://linux-ntfs.sf.net/ & http://www-stu.christs.cam.ac.uk/~aia21/
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2005-09-30 15:48 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-09-30 14:03 New and bogus(!) warning produced by sparse Anton Altaparmakov
2005-09-30 14:29 ` Linus Torvalds
2005-09-30 14:34 ` Linus Torvalds
2005-09-30 15:37 ` Linus Torvalds
2005-09-30 15:48 ` Anton Altaparmakov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®