* src/SDCCicode.c (fgeniCodeAssign): fixed bug 1369874, don't use volatile variables...
[fw/sdcc] / src / SDCCicode.c
index 5827d4e5032ed44d420103ba564cdf676110b03f..513c7b6ccee6a2aaf7cc8fe47e7d04f0465d9136 100644 (file)
@@ -3264,12 +3264,16 @@ geniCodeAssign (operand * left, operand * right, int nosupdate, int strictLval)
       isOperandGlobal (left))
     {
       symbol *sym = NULL;
+      operand *newRight;
 
       if (IS_TRUE_SYMOP (right))
         sym = OP_SYMBOL (right);
       ic = newiCode ('=', NULL, right);
-      IC_RESULT (ic) = right = newiTempOperand (ltype, 0);
-      SPIL_LOC (right) = sym;
+      IC_RESULT (ic) = newRight = newiTempOperand (ltype, 0);
+      /* avoid double fetch from volatile right, see bug 1369874 */
+      if (!isOperandVolatile (right, FALSE))
+        SPIL_LOC (newRight) = sym;
+      right = newRight;
       ADDTOCHAIN (ic);
     }