This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Problems shifting an int 32 times. Gcc 3.4.5
- From: Andrew Haley <aph at redhat dot com>
- To: Juan Reina <juanmr at web dot de>
- Cc: gcc-help at gcc dot gnu dot org
- Date: Tue, 24 Oct 2006 16:33:44 +0100
- Subject: Re: Problems shifting an int 32 times. Gcc 3.4.5
- References: <457682441@web.de>
Juan Reina writes:
> Hello:
>
> I have a problem using the shift operator, maybe a bug (ok, a bug or i'm wrong about shift operator)
>
> System: i386-redhat-linux
> Version: Gcc 3.4.5
> Case:
> In the next snipplet:
> unsigned int getMask(int n){
> unsigned int mask = 0;
> a = ~(~(a)<<n);
> }
>
> In case of n<32, the function works correct but if n=32, the value of a is 0 (when should be 0xFFFF).
Have a look at C99, Section 6.5.7 Para 3.
http://www.open-std.org/JTC1/SC22/WG14/www/docs/n1124.pdf