English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
[Caml-list] Bug? Printf, %X and negative numbers
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2003-03-31 (15:42)
From: Brian Hurt <brian.hurt@q...>
Subject: Re: [Caml-list] Bug? Printf, %X and negative numbers
On Sun, 30 Mar 2003, Xavier Leroy wrote:

> As Yutaka Oiwa said, it comes from the conversion from Caml 31-bit
> integers to C 32-bit integers, which performs sign extension.
> Even though 0x40000000 and 0xC0000000 denote the same Caml int, I
> agree this behavior is very surprising and should be fixed.  I'll look
> into this.  Thanks for reporting the issue.

Having looked at it a bit myself, the fix will probable be *ahem* 
interesting.  Effectively, you have to stop using C's printf.  Either 
that, or parse the format string a second (third?) time to see wether you 
need to do a signed or unsigned int conversion.  Or, I suppose, we could 
completely redesign Ocaml to use 32-bit ints and do something else to 
differentiate ints from pointers :-).

More pragmatically, I think this behavior should just be documented.  
"Broken as designed".  Once you know about it, it's annoying not critical.


To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners