Re: svn commit: r328159 - head/sys/modules

2018-01-20 Thread Konstantin Belousov
On Sat, Jan 20, 2018 at 07:57:55PM +1100, Bruce Evans wrote: > The not-unused x86 arch is one that does this. IIRC, some history of this > is: > > - on the 8086, the shift count was taken mod 32. 16 bits was enough for >anyone, and shifting left or right by 16 through 31 (but not by 32) >

Re: svn commit: r328159 - head/sys/modules

2018-01-20 Thread Bruce Evans
On Fri, 19 Jan 2018, Don Lewis wrote: On 19 Jan, Conrad Meyer wrote: On Fri, Jan 19, 2018 at 9:37 AM, Rodney W. Grimes wrote: If you think in assembler it is easy to understand why this is UB, most (all) architectures Right Logic or Arithmetic Shift only accept an operand that is a size that

Re: svn commit: r328159 - head/sys/modules

2018-01-19 Thread Mark Millard via svn-src-head
Conrad Meyer cem at freebsd.org wrote on Fri Jan 19 05:07:22 UTC 2018 : > The spec says the behavior is undefined; not that the compiler has to > produce a warning or error message. The compiler *does* get to > arbitrarily decide what it wants to do when it encounters UB. It is > wholly free to

Re: svn commit: r328159 - head/sys/modules

2018-01-19 Thread Don Lewis
On 19 Jan, Conrad Meyer wrote: > On Fri, Jan 19, 2018 at 9:37 AM, Rodney W. Grimes > wrote: >> If you think in assembler it is easy to understand why this is UB, >> most (all) architectures Right Logic or Arithmetic Shift only accept an >> operand that is a size that can hold log2(wordsize). > >

Re: svn commit: r328159 - head/sys/modules

2018-01-19 Thread Don Lewis
On 19 Jan, David Chisnall wrote: > On 19 Jan 2018, at 05:07, Conrad Meyer wrote: >> >> The spec says the behavior is undefined; not that the compiler has to >> produce a warning or error message. The compiler *does* get to >> arbitrarily decide what it wants to do when it encounters UB. It is >

Re: svn commit: r328159 - head/sys/modules

2018-01-19 Thread Mark Millard via svn-src-head
Andriy Gapon avg at FreeBSD.org wrote on Fri Jan 19 18:41:07 UTC 2018 : > On 19/01/2018 20:30, Conrad Meyer wrote: > > On Fri, Jan 19, 2018 at 9:37 AM, Rodney W. Grimes > > wrote: > >> If you think in assembler it is easy to understand why this is UB, > >> most (all) architectures Right Logic or

Re: svn commit: r328159 - head/sys/modules

2018-01-19 Thread Rodney W. Grimes
[ Charset UTF-8 unsupported, converting... ] > On Fri, Jan 19, 2018 at 9:51 AM, John Baldwin wrote: > > On Friday, January 19, 2018 04:34:06 AM Conrad Meyer wrote: > >> The logical result of a right shift >= the width of a type is zero, but > >> our > >> compiler decides this is a warning (an

Re: svn commit: r328159 - head/sys/modules

2018-01-19 Thread Warner Losh
On Fri, Jan 19, 2018 at 11:31 AM, Conrad Meyer wrote: > On Fri, Jan 19, 2018 at 9:51 AM, John Baldwin wrote: > > On Friday, January 19, 2018 04:34:06 AM Conrad Meyer wrote: > >> The logical result of a right shift >= the width of a type is zero, > but our > >> compiler decides this is a warn

Re: svn commit: r328159 - head/sys/modules

2018-01-19 Thread Andriy Gapon
On 19/01/2018 20:30, Conrad Meyer wrote: > On Fri, Jan 19, 2018 at 9:37 AM, Rodney W. Grimes > wrote: >> If you think in assembler it is easy to understand why this is UB, >> most (all) architectures Right Logic or Arithmetic Shift only accept an >> operand that is a size that can hold log2(wordsi

Re: svn commit: r328159 - head/sys/modules

2018-01-19 Thread Rodney W. Grimes
> On Friday, January 19, 2018 04:34:06 AM Conrad Meyer wrote: > > Author: cem > > Date: Fri Jan 19 04:34:06 2018 > > New Revision: 328159 > > URL: https://svnweb.freebsd.org/changeset/base/328159 > > > > Log: > > Unbreak i386 build > > > > The logical result of a right shift >= the width of

Re: svn commit: r328159 - head/sys/modules

2018-01-19 Thread Conrad Meyer
On Fri, Jan 19, 2018 at 9:37 AM, Rodney W. Grimes wrote: > If you think in assembler it is easy to understand why this is UB, > most (all) architectures Right Logic or Arithmetic Shift only accept an > operand that is a size that can hold log2(wordsize). This is a logical right shift by a constan

Re: svn commit: r328159 - head/sys/modules

2018-01-19 Thread Conrad Meyer
On Fri, Jan 19, 2018 at 9:51 AM, John Baldwin wrote: > On Friday, January 19, 2018 04:34:06 AM Conrad Meyer wrote: >> The logical result of a right shift >= the width of a type is zero, but our >> compiler decides this is a warning (and thus, error). Just remove ccp(4) >> from i386. > > You

Re: svn commit: r328159 - head/sys/modules

2018-01-19 Thread John Baldwin
On Friday, January 19, 2018 04:34:06 AM Conrad Meyer wrote: > Author: cem > Date: Fri Jan 19 04:34:06 2018 > New Revision: 328159 > URL: https://svnweb.freebsd.org/changeset/base/328159 > > Log: > Unbreak i386 build > > The logical result of a right shift >= the width of a type is zero, but

Re: svn commit: r328159 - head/sys/modules

2018-01-19 Thread Rodney W. Grimes
[ Charset UTF-8 unsupported, converting... ] > On Fri, Jan 19, 2018 at 6:56 AM, David Chisnall wrote: > > In C, a right-shift of a signed type propagates the sign bit. Right > > shifting a negative 32-bit int by 16 and then again by 16 is not undefined > > behaviour (though doing the shift as a

Re: svn commit: r328159 - head/sys/modules

2018-01-19 Thread Conrad Meyer
On Fri, Jan 19, 2018 at 6:56 AM, David Chisnall wrote: > In C, a right-shift of a signed type propagates the sign bit. Right shifting > a negative 32-bit int by 16 and then again by 16 is not undefined behaviour > (though doing the shift as a single operation is) and will give you a value > of

Re: svn commit: r328159 - head/sys/modules

2018-01-19 Thread David Chisnall
On 19 Jan 2018, at 05:07, Conrad Meyer wrote: > > The spec says the behavior is undefined; not that the compiler has to > produce a warning or error message. The compiler *does* get to > arbitrarily decide what it wants to do when it encounters UB. It is > wholly free to implement this particul

Re: svn commit: r328159 - head/sys/modules

2018-01-19 Thread Peter Jeremy
On 2018-Jan-18 21:07:19 -0800, Conrad Meyer wrote: >The spec says the behavior is undefined; not that the compiler has to >produce a warning or error message. The compiler *does* get to >arbitrarily decide what it wants to do when it encounters UB. It is >wholly free to implement this particular

Re: svn commit: r328159 - head/sys/modules

2018-01-18 Thread Conrad Meyer
The spec says the behavior is undefined; not that the compiler has to produce a warning or error message. The compiler *does* get to arbitrarily decide what it wants to do when it encounters UB. It is wholly free to implement this particular UB with the logical result and no warning/error. On Th

Re: svn commit: r328159 - head/sys/modules

2018-01-18 Thread Conrad Meyer
No. It is the only logical result of a logical right shift larger than the left operand. The C standard may claim that is undefined, but that does not change the only logical result (zero). On Thu, Jan 18, 2018 at 8:38 PM, Benjamin Kaduk wrote: > On Thu, Jan 18, 2018 at 10:34 PM, Conrad Meyer

Re: svn commit: r328159 - head/sys/modules

2018-01-18 Thread Benjamin Kaduk
On Thu, Jan 18, 2018 at 10:49 PM, Conrad Meyer wrote: > No. It is the only logical result of a logical right shift larger > than the left operand. The C standard may claim that is undefined, > but that does not change the only logical result (zero). > > My point is that the compiler does not ar

Re: svn commit: r328159 - head/sys/modules

2018-01-18 Thread Benjamin Kaduk
On Thu, Jan 18, 2018 at 10:34 PM, Conrad Meyer wrote: > Author: cem > Date: Fri Jan 19 04:34:06 2018 > New Revision: 328159 > URL: https://svnweb.freebsd.org/changeset/base/328159 > > Log: > Unbreak i386 build > > The logical result of a right shift >= the width of a type is zero, but > our >

svn commit: r328159 - head/sys/modules

2018-01-18 Thread Conrad Meyer
Author: cem Date: Fri Jan 19 04:34:06 2018 New Revision: 328159 URL: https://svnweb.freebsd.org/changeset/base/328159 Log: Unbreak i386 build The logical result of a right shift >= the width of a type is zero, but our compiler decides this is a warning (and thus, error). Just remove ccp(