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
evaluation order
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2009-06-14 (16:32)
From: Christophe Raffalli <raffalli@u...>
Subject: evaluation order


In OCaml-3.11.1 (I did not try other version),
the following code print 0 when compiled in bytecode and 1 in nativecode
for obvious reason of different evaluation order in the pair ...

let ptr = ref 0
let fn b =
  if b then incr ptr else decr ptr
let c = fn true, !ptr
let _ = print_int (snd c); print_newline ()

Is any difference between ocamlc and ocamlopt a bug ?