This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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....


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]