Is this a bug?

Matthew Toseland toad@amphibian.dyndns.org
Thu Feb 6 21:33:00 GMT 2003


#include <stdio.h>

void main() {
        int x = 1;
        int y = x << 32;
        int z = (x << 32);
        int q = 32;
        printf("1 << 32 = %x = %x\n", (1L << 32), (1LL << 32));
	printf("1 << 32 = %x = %x\n", (1UL << 32), (1ULL << 32));
	printf("1 << 32 = %x = %x\n", (x << 32), (z << 32));
        printf("1 << 32 = %x = %%x\n", %(x << %q), (z %<< q));
}

Returns 

1 << 32 = 0 = 0
1 << 32 = 0 = 0
1 << 32 = 1 = 1
1 << 32 = 1 = 1


Is this the defined behaviour? (1L << 32) is different from (x << 32)
where x is an int defined to 1?
								
-- 
Matthew Toseland
toad@amphibian.dyndns.org/amphibian@users.sourceforge.net
Full time freenet hacker.
http://freenetproject.org/
Freenet Distribution Node (temporary) at http://amphibian.dyndns.org:8889/27rV~CifX54/
ICTHUS.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-bugs/attachments/20030206/42ed408f/attachment.sig>


More information about the Gcc-bugs mailing list