Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
[Caml-list] Re: Marshalling tests fail on AMD x86_64 (Opteron). (PR#1979)
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2003-12-20 (16:45)
From: John Carr <jfc@M...>
Subject: Re: [Caml-list] Re: Marshalling tests fail on AMD x86_64 (Opteron). (PR#1979)

> The first test failure is either a bug in gcc or an unspecified
> behavior of C that I wasn't aware of.  Basically, some stuff is
> computed with type 'unsigned int', stored in an 'unsigned long'
> variable, and compared against an 'unsigned int' constant.

It isn't generated with type unsigned int.  The read32u macro
in the attached file yields an int, not an unsigned int, because
(unsigned char) promotes to (signed int).  If I change "long" to
"long long" in the attached file and compile with gcc on x86 the
program prints "Bug".

This is your macro definition:

#define read32u() \
  (src += 4, \
   (src[-4] << 24) + (src[-3] << 16) + (src[-2] << 8) + src[-1])

Try adding a cast:

#define read32u() \
  (src += 4, \
   (unsigned int)((src[-4] << 24) + (src[-3] << 16) + (src[-2] << 8) + src[-1]))

To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: