lkml.org 
[lkml]   [2006]   [Nov]   [3]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: New filesystem for Linux


On Fri, 3 Nov 2006, Oleg Verych wrote:

> On Fri, Nov 03, 2006 at 06:09:39PM +0100, Mikulas Patocka wrote:
>>> In gmane.linux.kernel, you wrote:
>>> []
>>>> From: Andrew Morton <akpm@osdl.org>
>>>>
>>>> As Mikulas points out, (1 << anything) won't be evaluating to zero.
>>>
>>> How about integer overflow ?
>>
>> C standard defines that shifts by more bits than size of a type are
>> undefined (in fact 1<<32 produces 1 on i386, because processor uses only 5
>> bits of a count).
> ,--
> |#include <stdio.h>
> |int main(void) {
> | unsigned int b = 1;
> |
> | printf("%u\n", (1 << 33));
> | printf("%u\n", (b << 33));
> | return 0;
> |}
> |$ gcc bit.c && ./a.out
> `--
>
> There *is* difference, isn't it?

The standard says that the result is undefined, so the compiler is
standard-compliant. It could have returned any numbers and still be
correct.

Mikulas
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2006-11-03 19:17    [W:0.053 / U:0.508 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site