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 KAA14525; Tue, 1 Apr 2003 10:20:04 +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 KAA13709 for ; Tue, 1 Apr 2003 10:20:03 +0200 (MET DST) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id h318Jk520432; Tue, 1 Apr 2003 10:19:47 +0200 (MET DST) Received: (from xleroy@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id KAA14864; Tue, 1 Apr 2003 10:19:46 +0200 (MET DST) Date: Tue, 1 Apr 2003 10:19:46 +0200 From: Xavier Leroy To: Brian Hurt Cc: Ocaml Mailing List Subject: Re: [Caml-list] Bug? Printf, %X and negative numbers Message-ID: <20030401101946.B14164@pauillac.inria.fr> References: <20030330115111.A22539@pauillac.inria.fr> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 1.0i In-Reply-To: ; from brian.hurt@qlogic.com on Mon, Mar 31, 2003 at 09:44:28AM -0600 X-Spam: no; 0.00; caml-list:01 bug:01 printf:01 ahem:01 c's:01 wether:01 camlcvs:01 buffer:01 byterun:01 redesign:01 pointers:01 boxing:01 compiler:01 -bit:01 ints:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk > 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. It's no big deal, really. (See the working sources on camlcvs.inria.fr.) The formats are already parsed three(!) times: - once in Caml (module Printf) - once in C to determine the size of the buffer to hold the result (file byterun/ints.c) - once in the printf() C library function itself. The way I fixed it, the signed/unsigned distinction is done in the second parsing, although it could also be done during the first. > Or, I suppose, we could > completely redesign Ocaml to use 32-bit ints and do something else to > differentiate ints from pointers :-). If you can find a "something else" that is faster than systematically boxing the 32-bit ints, you'll be hailed as the savior in compiler circles :-) - Xavier Leroy ------------------- 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