svn commit: r328159 - head/sys/modules

Conrad Meyer cem at freebsd.org
Fri Jan 19 04:55:15 UTC 2018


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 at gmail.com> wrote:
> On Thu, Jan 18, 2018 at 10:34 PM, Conrad Meyer <cem at 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


More information about the svn-src-head mailing list