From mboxrd@z Thu Jan 1 00:00:00 1970 From: Steve Sun To: gcc-bugs@gcc.gnu.org Subject: Bug Report Date: Wed, 23 May 2001 12:10:00 -0000 Message-id: <20010523.19155200@otl.gte.com> X-SW-Source: 2001-05/msg00697.html List-Id: Dear Sir, I was surprised by the result of this simple program compiling with gcc 2.95 on Red Hat Linux 7.0. Could you check whether is it a bug of gcc 2.95 (for Red Hat Linux 7.0)? Sincerely, Stephen Sun #include main() { char *ptr, arr[4]; int id = 50724871; /* id: 00000011 00000110 00000000 00000111 */ ptr = (char *) &id; /* ptr points to leftmost bit of id */ arr[0] = *(ptr); /* arr[0] = left-most byte of id */ arr[1] = *(ptr + 1); /* arr[1] = 2nd byte of id */ arr[2] = *(ptr + 2); /* arr[2] = 3rd byte of id */ arr[3] = *(ptr + 3); /* arr[3] = right-most byte of id */ printf("size of int = %d bytes.\n", sizeof(int)); printf("arr[0] = %d, should be 3.\n", (int) arr[0]); printf("arr[1] = %d, should be 6.\n", (int) arr[1]); printf("arr[2] = %d, should be 0.\n", (int) arr[2]); printf("arr[3] = %d, should be 7.\n", (int) arr[3]); return 0; }