--- mercury/runtime/mercury_stm.c	2011-05-20 00:16:55.000000000 -0400
+++ mercury-compiler-11.07-beta-2011-09-30-modded/runtime/mercury_stm.c	2011-10-24 19:37:24.723339594 -0400
@@ -264,6 +264,7 @@
 {
     MR_STM_TransLog     *current_tlog;
     MR_STM_TransRecord  *current;
+    MR_Word             value;
 
     current_tlog = tlog;
 
@@ -293,10 +294,10 @@
     ** Add an entry that indicates that it has been read and then return
     ** the value that is stored in the transaction variable.
     */
-    MR_STM_record_transaction(tlog, var, var->MR_STM_var_value,
-        var->MR_STM_var_value);
+    value = var->MR_STM_var_value;
+    MR_STM_record_transaction(tlog, var, value, value);
 
-    return var->MR_STM_var_value;
+    return value;
 }
 
 void
