warning: right shift count >= width of type
Dave Korn
dk@artimi.com
Mon Nov 29 19:46:00 GMT 2004
> -----Original Message-----
> From: Chris Jefferson
> Sent: 29 November 2004 19:07
> 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
Well, if the compiler can issue a warning, it could also in theory do
something about it. It's not an "extension", since *anything* the compiler
does is valid according to the standard. And the truth is I was only
interested in catching obvious cases, so that you can write something like
ARBITRARY_INT_TYPE x, y, z;
/* Separate x into 32-bit chunks */
y = (x >> 32) & 0xffffffffUL;
z = x & 0xffffffffUL;
and have it DTRT regardless of whether the int's are 32 or 64 bits wide
naturally....
cheers,
DaveK
--
Can't think of a witty .sigline today....
More information about the Gcc
mailing list