This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
RE: warning: right shift count >= width of type
- From: "Dave Korn" <dk at artimi dot com>
- To: "'Chris Jefferson'" <caj at cs dot york dot ac dot uk>
- Cc: "'Dale Johannesen'" <dalej at apple dot com>,<gcc at gcc dot gnu dot org>,"'Andrew Haley'" <aph at redhat dot com>,"'Nathan Sidwell'" <nathan at codesourcery dot com>
- Date: Mon, 29 Nov 2004 19:16:21 -0000
- Subject: RE: warning: right shift count >= width of type
> -----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....