From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id RAA27728; Mon, 31 Mar 2003 17:42:53 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id RAA27658 for ; Mon, 31 Mar 2003 17:42:52 +0200 (MET DST) Received: from epexch01.qlogic.org ([63.170.40.3]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id h2VFgm501614; Mon, 31 Mar 2003 17:42:48 +0200 (MET DST) Received: from epmailtmp.qlogic.org ([10.20.33.254]) by epexch01.qlogic.org with Microsoft SMTPSVC(5.0.2195.5329); Mon, 31 Mar 2003 09:43:24 -0600 Received: from [10.20.33.146] ([10.20.33.146]) by epmailtmp.qlogic.org with Microsoft SMTPSVC(5.0.2195.4905); Mon, 31 Mar 2003 09:43:23 -0600 Date: Mon, 31 Mar 2003 09:44:28 -0600 (CST) From: Brian Hurt X-X-Sender: Reply-To: Brian Hurt To: Xavier Leroy cc: Brian Hurt , Ocaml Mailing List Subject: Re: [Caml-list] Bug? Printf, %X and negative numbers In-Reply-To: <20030330115111.A22539@pauillac.inria.fr> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-OriginalArrivalTime: 31 Mar 2003 15:43:23.0804 (UTC) FILETIME=[436E0DC0:01C2F79C] X-Spam: no; 0.00; qlogic:01 caml-list:01 bug:01 printf:01 yutaka:01 oiwa:01 ahem:01 c's:01 wether:01 redesign:01 pointers:01 -bit:01 ints:01 ocaml:01 caml:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk 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. Brian ------------------- 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