Date: Thu, 18 Jan 2018 20:49:42 -0800 From: Conrad Meyer <cem@freebsd.org> To: Benjamin Kaduk <bjkfbsd@gmail.com> Cc: src-committers <src-committers@freebsd.org>, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r328159 - head/sys/modules Message-ID: <CAG6CVpVhLcY5ohnHW32raKic7MT5Q%2B7C9EA9dzwpQvbUXVH%2Big@mail.gmail.com> In-Reply-To: <CAJ5_RoAhGgkQTLXgHpYYOiupA=c6wK%2BpeAdT0Zjaw0n-ggAd1g@mail.gmail.com> References: <201801190434.w0J4Y6i7086677@repo.freebsd.org> <CAJ5_RoAhGgkQTLXgHpYYOiupA=c6wK%2BpeAdT0Zjaw0n-ggAd1g@mail.gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
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 <bjkfbsd@gmail.com> wrote: > On Thu, Jan 18, 2018 at 10:34 PM, Conrad Meyer <cem@freebsd.org> 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 >> compiler decides this is a warning (and thus, error). Just remove >> ccp(4) >> from i386. > > > That may seem like the logical result, but this is actually undefined > behavior. Per n1256.pdf, section 6.5.7: > > The integer promotions are performed on each of the operands. The type of > the result is that of the promoted left operand. If the value of the right > operand is negative or is greater than or equal to the width of the promoted > left operand, the behavior is undefined. > > -Ben
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAG6CVpVhLcY5ohnHW32raKic7MT5Q%2B7C9EA9dzwpQvbUXVH%2Big>