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: "'Dale Johannesen'" <dalej at apple dot com>,"'Andrew Haley'" <aph at redhat dot com>
- Cc: <gcc at gcc dot gnu dot org>,"'Nathan Sidwell'" <nathan at codesourcery dot com>
- Date: Mon, 29 Nov 2004 19:18:25 -0000
- Subject: RE: warning: right shift count >= width of type
> -----Original Message-----
> From: Dale Johannesen
> Sent: 29 November 2004 18:57
> On Nov 29, 2004, at 10:51 AM, Andrew Haley wrote:
> >> I myself would want "(n >> 32)" to produce the same
> result as "((n
> >> >> 16)
> >>>> 16)" and indeed "for (int i = 32; i > 0; i--, n >>= 1)
> ;", and it
> >>>> seems
> >> to be generally agreed that the compiler would be at
> liberty to so do
> >> if it
> >> wants to.
> >
> > But you could never depend on it. If it only works when the shift
> > count is a constant, a failure to do constant folding would
> break it.
>
> Or constant propagation, or inlining, or ...
>
Ah. Good point.
Of course, in such cases, the compiler will also fail to produce the warning
message too.......
cheers,
DaveK
--
Can't think of a witty .sigline today....