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]

RE: Bug Report


> 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


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