diff --git a/src/LambertW.cc b/src/LambertW.cc
index 0c0ae500c26a2174cb507e9779fa26e1ce00dd3f..ff5e933a05e15892b552b948706a0ff3bb01bab7 100644
--- a/src/LambertW.cc
+++ b/src/LambertW.cc
@@ -324,15 +324,17 @@ template <double IterationStep(const double x, const double w)>
 struct Iterator {
 
   static double Do(const int n, const double x, const double w) {
+    double tmpw = w;
     for (int i = 0; i < n; ++i)
-      w = IterationStep(x, w);
-    return w;
+      tmpw = IterationStep(x, tmpw);
+    return tmpw;
   }
 
   template <int n> static double Do(const double x, const double w) {
+    double tmpw = w;
     for (int i = 0; i < n; ++i)
-      w = IterationStep(x, w);
-    return w;
+      tmpw = IterationStep(x, tmpw);
+    return tmpw;
   }
 
   template <int n, class = void> struct Depth {