lkml.org 
[lkml]   [2017]   [Jun]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] futex: avoid undefined behaviour when shift exponent is negative
On 2017/6/29 14:33, Thomas Gleixner wrote:
> On Thu, 29 Jun 2017, zhong jiang wrote:
>> On 2017/6/29 6:13, Thomas Gleixner wrote:
>>> That's simply wrong. If oparg is negative and the SHIFT bit is set then the
>>> result is undefined today and there is no way that this can be used at
>>> all.
>>>
>>> On x86:
>>>
>>> 1 << -1 = 0x80000000
>>> 1 << -2048 = 0x00000001
>>> 1 << -2047 = 0x00000002
>> but I test the cases in x86_64 all is zero. I wonder whether it is related to gcc or not
>>
>> zj.c:15:8: warning: left shift count is negative [-Wshift-count-negative]
>> j = 1 << -2048;
>> ^
>> [root@localhost zhongjiang]# ./zj
>> j = 0
> Which is not a surprise because the compiler can detect it as the shift is
> a constant. oparg is not so constant ...
I get it. Thanks

Thanks
zhongjiang
> Thanks,
>
> tglx
>
> .
>


\
 
 \ /
  Last update: 2017-06-29 09:05    [W:0.071 / U:0.208 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site