Subject: Re: gcc/egcs problem with shifts on i386
To: Colin Wood <>
From: None <>
List: current-users
Date: 08/16/1999 23:10:24
In message <>, Colin Wood writes:
>i wrote a little program to play with shifts today (i needed it for work)
>and discovered a problem with shifts under i386 (or IA32 as we like to say
>here at work ;-)  the program is included below for reference.  what i've
>found is that if i specify a shift count of 32 for either a right or left
>shift (i.e num << 32), i get back the same number i put in, rather than a

I see no problem here.  For n-bit numbers, C says that shifts of n bits are
undefined behavior.

>this only appears to occur on i386 (and i can probably explain it fairly
>easily if a shift is implemented via SHL/SHR).  what i'm wondering is if
>this is a bug in egcs/gcc, or if this is simply a hole in the C spec and
>either behavior is allowed.

It's not a hole, it's a feature.  :)