Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1677438
| From | Thomas Gleixner <tglx@linutronix.de> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH] futex: avoid undefined behaviour when shift exponent is negative |
| Date | 2017-06-29 08:40 +0200 |
| Message-ID | <tXBho-47z-13@gated-at.bofh.it> (permalink) |
| References | <tUQZk-aB-21@gated-at.bofh.it> <tUQZk-aB-19@gated-at.bofh.it> <tXcVI-27M-11@gated-at.bofh.it> <tXttw-ZE-11@gated-at.bofh.it> <tXwUq-1c2-9@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
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 ... Thanks, tglx
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Re: [PATCH] futex: avoid undefined behaviour when shift exponent is negative Ingo Molnar <mingo@kernel.org> - 2017-06-21 18:50 +0200
Re: [PATCH] futex: avoid undefined behaviour when shift exponent is negative zhong jiang <zhongjiang@huawei.com> - 2017-06-28 06:40 +0200
Re: [PATCH] futex: avoid undefined behaviour when shift exponent is negative hpa@zytor.com - 2017-06-28 23:50 +0200
Re: [PATCH] futex: avoid undefined behaviour when shift exponent is negative zhong jiang <zhongjiang@huawei.com> - 2017-06-29 04:20 +0200
Re: [PATCH] futex: avoid undefined behaviour when shift exponent is negative hpa@zytor.com - 2017-06-29 06:40 +0200
Re: [PATCH] futex: avoid undefined behaviour when shift exponent is negative zhong jiang <zhongjiang@huawei.com> - 2017-06-29 08:10 +0200
Re: [PATCH] futex: avoid undefined behaviour when shift exponent is negative Thomas Gleixner <tglx@linutronix.de> - 2017-06-29 00:20 +0200
Re: [PATCH] futex: avoid undefined behaviour when shift exponent is negative zhong jiang <zhongjiang@huawei.com> - 2017-06-29 04:00 +0200
Re: [PATCH] futex: avoid undefined behaviour when shift exponent is negative Thomas Gleixner <tglx@linutronix.de> - 2017-06-29 08:40 +0200
Re: [PATCH] futex: avoid undefined behaviour when shift exponent is negative zhong jiang <zhongjiang@huawei.com> - 2017-06-29 09:10 +0200
csiph-web