warning: right shift count >= width of type
Chris Jefferson
caj@cs.york.ac.uk
Mon Nov 29 19:19:00 GMT 2004
Dave Korn wrote:
>>-----Original Message-----
>>From: Chris Jefferson
>>Sent: 29 November 2004 17:13
>>
>>
>
>
>
>>> So my question is really "Given that it's undefined, which
>>>
>>>
>>means that
>>
>>
>>>whatever the compiler does is correct, and given that
>>>
>>>
>>there's already code
>>
>>
>>>in there to detect the situation and issue a warning, which
>>>
>>>
>>probably means
>>
>>
>>>that it would be very easy at such a point to replace the
>>>
>>>
>>offending RTL with
>>
>>
>>>(const_int 0), is there any specific reason why not to?"
>>>
>>>
>>>
>>One reason (of course) not to would be if you are bit-shifting by a
>>variable. Adding a check at runtime to see if the value of
>>this variable
>>is <32 and if not setting the variable to zero would be
>>frowned upon by
>>many people, particuarily because the kind of people who undertake
>>bitshifting are doing it for performance-related reasons...
>>
>>Chris
>>
>>
>
> What on earth made you suppose I would for one instant suggest anything so
>ridiculous? I was talking about static compile-time checking.
>
>
>
I apologise. Then I would instead ask why you would want to add some
compiler-specific extension that may or may not activate depending upon
the current level of optimisation? Or would you forbid this optimisation
if gcc can deduce an expression is constant when it isn't obvious
without optimisation?
Chris
More information about the Gcc
mailing list