--- a/src/h/stacks.h
+++ b/src/h/stacks.h
@@ -52,10 +52,11 @@
 extern ECL_API void ecl_bds_unwind_n(cl_env_ptr env, int n);
 #ifdef ECL_THREADS
 extern ECL_API cl_object ecl_bds_read(cl_env_ptr env, cl_object s);
+extern ECL_API cl_object *ecl_bds_ref(cl_env_ptr env, cl_object s);
 extern ECL_API cl_object ecl_bds_set(cl_env_ptr env, cl_object s, cl_object v);
 # define ECL_SYM_VAL(env,s) (ecl_bds_read(env,s))
 # define ECL_SET(s,v) ((s)->symbol.value=(v))
-# define ECL_SETQ(env,s,v) (ecl_bds_set(env,s,v))
+# define ECL_SETQ(env,s,v) (*ecl_bds_ref(env,s)=(v))
 #else
 # define ECL_SYM_VAL(env,s) ((s)->symbol.value)
 # define ECL_SET(s,v) ((s)->symbol.value=(v))
@@ -134,17 +135,17 @@
         }
         return s->symbol.value;
 }
-static inline cl_object ecl_bds_set_inl(cl_env_ptr env, cl_object s, cl_object v)
+static inline cl_object *ecl_bds_ref_inl(cl_env_ptr env, cl_object s)
 {
         cl_index index = s->symbol.binding;
         if (index < env->thread_local_bindings_size) {
                 cl_object *location = env->thread_local_bindings + index;
-                if (*location != ECL_NO_TL_BINDING) return *location = v;
+                if (*location != ECL_NO_TL_BINDING) return location;
         }
-        return s->symbol.value = v;
-}
+	return &s->symbol.value;
+}
+#  define ecl_bds_set(env,s,v) (*ecl_bds_ref_inl(env,s)=(v))
 #  define ecl_bds_read ecl_bds_read_inl
-#  define ecl_bds_set ecl_bds_set_inl
 # endif
 # define ecl_bds_bind ecl_bds_bind_inl
 # define ecl_bds_push ecl_bds_push_inl