diff --git a/loopy/target/pyopencl.py b/loopy/target/pyopencl.py
index 9955705a2fbca26d12dad95b45d2f547ad778568..186c2e85c664381e8c470fcb1570372500a196a8 100644
--- a/loopy/target/pyopencl.py
+++ b/loopy/target/pyopencl.py
@@ -61,6 +61,10 @@ def adjust_local_temp_var_storage(kernel, device):
                     temp_var.copy(storage_shape=temp_var.shape)
             continue
 
+        if not temp_var.shape:
+            # scalar, no need to mess with storage shape
+            continue
+
         other_loctemp_nbytes = [
                 tv.nbytes
                 for tv in six.itervalues(kernel.temporary_variables)