This is the mail archive of the gcc-bugs@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]

Is this a bug?


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

Attachment: msg00299/pgp00000.pgp
Description: PGP signature


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