caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Michael Wohlwend <micha-1@fantasymail.de>
To: caml-list@inria.fr
Subject: compiler question
Date: Sat, 22 Jul 2006 21:19:15 +0200	[thread overview]
Message-ID: <200607222119.15681.micha-1@fantasymail.de> (raw)

Hi,

I executed the following code,  the array a0 was allocated to match the 
filesize and get32 reads 4 bytes via input_byte:

  let idx = ref 0 in
  try
    while true do
      a0.(!idx) <-get32 file;
      incr idx;
    done
  with
    End_of_file -> close_in file;


this code works as bytecode but gives an array exception when compiled to 
native code. Is the execution order different on the two compilers? The a0.
(!idx) get evaluted before the get32 in native-code, but with bytecode the 
get32 is computed first (it seems).
The code works if I add a temporary variable like:
let t = get32 file in
a0.(!idx) <- t;

is this a feature ? :-)
cheers,
 Michael


             reply	other threads:[~2006-07-22 19:18 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-07-22 19:19 Michael Wohlwend [this message]
2006-07-23  7:58 ` [Caml-list] " Richard Jones

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200607222119.15681.micha-1@fantasymail.de \
    --to=micha-1@fantasymail.de \
    --cc=caml-list@inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).