This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
RE: Bug Report
- To: "Steve Sun" <ss01 at gte dot com>, <gcc-bugs at gcc dot gnu dot org>
- Subject: RE: Bug Report
- From: "Tuukka Tikkanen" <tic0 at teraflops dot com>
- Date: Wed, 23 May 2001 23:09:48 +0300
> 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)?
You are forgetting the endianess of x86 processors. The behaviour is exactly
correct (ie. the numbers are printed in reverse order) for intel-based
system whereas you will (and should) get different result on for example
motorola 68000-based system.
If you need to write code that is portable (and if you need to play with
byte order) you should either use htonl(),htons(),ntohl(),ntohs() macros or
#include endian.h and use the __BYTE_ORDER, __BIG_ENDIAN and __LITTLE_ENDIAN
definitions.
Tuukka