lkml.org 
[lkml]   [2013]   [Feb]   [20]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: Undefined Code in .../include/linux.bitops.h
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


\
 
 \ /
  Last update: 2013-02-20 18:01    [W:0.042 / U:0.232 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site