public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Clemens Ladisch <clemens@ladisch.de>
To: noloader@gmail.com
Cc: linux-kernel@vger.kernel.org
Subject: Re: Undefined Code in .../include/linux.bitops.h
Date: Wed, 20 Feb 2013 17:10:25 +0100	[thread overview]
Message-ID: <5124F571.4060503@ladisch.de> (raw)
In-Reply-To: <CAH8yC8kQ1fqpaNXupkO+Rpaocw6gC3-kZuPpwD-DYds8hQ3SaQ@mail.gmail.com>

Jeffrey Walton wrote:
> http://www.tux.org/lkml/ is a tough read, and Item 4, "I think I found
> a bug, how do I report it?" does not tell me how to report this.

>From that page:
| A bug is when something (in the kernel, presumably) doesn't behave the
| way it should

So just tell us what it is that doesn't behave the way it should.

> According to Section 5.8, "Shift Operators" of
> http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2798.pdf:

The kernel doesn't try to be fully standard conformant.

>     return (word >> shift) | (word << (32 - shift));

> "The behavior is undefined if the right operand is ... equal to the
> length in bits of the promoted left operand."
>
> If I ask for a shift of 0

Does the kernel ever do this?

> the various ops will perform `32 - shift` (or `64 - shift`, etc). That
> means the right operand *IS* equal to the length in bits of the
> operand, so the code is undefined.

In practice, what CPUs actually do is to shift either by zero or by the
full 32/64 bits.  Both implementations give the correct result.


Regards,
Clemens

  reply	other threads:[~2013-02-20 16:11 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-02-20 15:11 Undefined Code in .../include/linux.bitops.h Jeffrey Walton
2013-02-20 16:10 ` Clemens Ladisch [this message]
2013-02-20 17:21   ` Jeffrey Walton

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=5124F571.4060503@ladisch.de \
    --to=clemens@ladisch.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=noloader@gmail.com \
    /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