[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <5954A66D.0@huawei.com>
Date: Thu, 29 Jun 2017 15:04:13 +0800
From: zhong jiang <zhongjiang@...wei.com>
To: Thomas Gleixner <tglx@...utronix.de>
CC: Ingo Molnar <mingo@...nel.org>, <akpm@...ux-foundation.org>,
<mingo@...hat.com>, <minchan@...nel.org>, <mhocko@...e.com>,
<hpa@...or.com>, <x86@...nel.org>, <linux-mm@...ck.org>,
<linux-kernel@...r.kernel.org>
Subject: Re: [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@...alhost 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
>
> .
>
Powered by blists - more mailing lists