From: Matthew Wilcox <matthew@wil.cx>
To: kernel-janitors@vger.kernel.org
Subject: Re: [KJ][Patch] remove implicit sign bit in msp3400.h
Date: Sun, 19 Feb 2006 06:58:35 +0000 [thread overview]
Message-ID: <20060219065835.GX12822@parisc-linux.org> (raw)
In-Reply-To: <1139380004.9409.40.camel@localhost.localdomain>
[-- Attachment #1: Type: text/plain, Size: 1077 bytes --]
On Sat, Feb 18, 2006 at 03:33:12PM +0300, Alexey Dobriyan wrote:
> It's very logical.
>
> int a:1;
>
> means 1 bit for sign (it's int) + >=1 bit for absolute value (it's int).
> So, >=2 bits you should somehow fit into 1 bit.
Standard 2's-complement representation. The MSB is negative. So
instead of the bits meaning 1, 2, 4, 8, 16, 32, 64, 128, the top bit
represents -128. So the one bit case represents -1.
ie the two values it can have are 0 and -1.
> I guess C standard says "undefined behaviour" or "implementation-defined".
It does ... sort of:
6.7.2:
for bit-fields, it is implementation-defined whether the specifier int
designates the same type as signed int or the same type as unsigned int.
so relying on int to be signed was already broken.
> BTW, someone could do
>
> int a:1;
> if (a < 0)
>
> so every time type is flipped, submitter should check every usage of "a".
>
> _______________________________________________
> Kernel-janitors mailing list
> Kernel-janitors@lists.osdl.org
> https://lists.osdl.org/mailman/listinfo/kernel-janitors
[-- Attachment #2: Type: text/plain, Size: 168 bytes --]
_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/kernel-janitors
prev parent reply other threads:[~2006-02-19 6:58 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-02-08 6:26 [KJ][Patch] remove implicit sign bit in msp3400.h Darren Jenkins\
2006-02-08 7:02 ` [KJ][Patch] remove implicit sign bit in l64781.c Darren Jenkins\
2006-02-08 7:17 ` [KJ][Patch] remove implicit sign bit in isdnhdlc.h Darren Jenkins\
2006-02-08 15:32 ` [KJ][Patch] remove implicit sign bit in msp3400.h Randy.Dunlap
2006-02-09 12:15 ` Darren Jenkins\
2006-02-18 12:33 ` Alexey Dobriyan
2006-02-19 6:32 ` Darren Jenkins\
2006-02-19 6:58 ` Matthew Wilcox [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20060219065835.GX12822@parisc-linux.org \
--to=matthew@wil.cx \
--cc=kernel-janitors@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.