public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: Alexandre Oliva <aoliva@redhat.com>
To: Ingo Krabbe <i.krabbe@dokom.net>
Cc: David Berthelot <davidb@Magma-DA.COM>,
	Ben Kohlen <bckohlen@yahoo.com>, <gcc-help@gcc.gnu.org>
Subject: Re: bug?
Date: Wed, 20 Jun 2001 07:57:00 -0000	[thread overview]
Message-ID: <orwv68a25z.fsf@guarana.lsd.ic.unicamp.br> (raw)
In-Reply-To: <Pine.LNX.4.33.0106191448210.22643-100000@flathead.burg.de>

On Jun 19, 2001, Ingo Krabbe <ikrabbe@earthling.net> wrote:

> On 19 Jun 2001, Alexandre Oliva wrote:
>> > That's a kind of why I used ~(~(x^x)<<(sizeof(x)*8-n)).

>> Make the `8' `CHAR_BIT'.  BTW, did you consider what happens if x is
>> narrower than size_t (the type of sizeof(x)) for both signed and
>> unsigned integer types?

> Hmm, I considered that sizeof(x) returns the size of bytes which has a
> length of 8 though a char may be longer ?!

sizeof(char) is always 1, but there's no guarantee that 1 byte will
contain exactly 8 bits.  That's where CHAR_BIT comes into play.

> Then I considered that ~(x^x) gives a stream of '1' as long as x.

Right.  But then, the shift operation causes the result to be promoted
to a type at least as wide as size_t.  This may cause sign extension,
if x is a signed type, or zero extension, if x is unsigned.  So, you
may get different bit patterns depending on the signedness of x.

-- 
Alexandre Oliva   Enjoy Guarana', see http://www.ic.unicamp.br/~oliva/
Red Hat GCC Developer                  aoliva@{cygnus.com, redhat.com}
CS PhD student at IC-Unicamp        oliva@{lsd.ic.unicamp.br, gnu.org}
Free Software Evangelist    *Please* write to mailing lists, not to me

  reply	other threads:[~2001-06-20  7:57 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-06-15 15:57 bug? Ben Kohlen
2001-06-15 16:38 ` bug? David Berthelot
2001-06-15 18:59 ` bug? Alexandre Oliva
2001-06-17  2:55 ` bug? Ingo Krabbe
2001-06-18 10:06   ` bug? David Berthelot
2001-06-18 11:46     ` bug? Ingo Krabbe
2001-06-18 23:05       ` bug? Alexandre Oliva
2001-06-18 23:58         ` bug? Ingo Krabbe
2001-06-19  0:31           ` bug? Alexandre Oliva
2001-06-19  5:55             ` bug? Ingo Krabbe
2001-06-20  7:57               ` Alexandre Oliva [this message]
2002-02-06  4:34 Bug???? kabir.patel
2003-09-20  7:45 Bug? Brian
2005-08-25 23:33 bug? Alexey Sokolov
2005-08-26  1:06 ` bug? corey taylor
2005-08-26 12:07 ` bug? Eljay Love-Jensen
2007-10-21 14:27 bug? skaller
2007-10-22 11:19 ` bug? John Love-Jensen
2007-10-23  8:04   ` bug? skaller

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=orwv68a25z.fsf@guarana.lsd.ic.unicamp.br \
    --to=aoliva@redhat.com \
    --cc=bckohlen@yahoo.com \
    --cc=davidb@Magma-DA.COM \
    --cc=gcc-help@gcc.gnu.org \
    --cc=i.krabbe@dokom.net \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).