diff --git a/pyopencl/scan.py b/pyopencl/scan.py
index 9692233daca57ec19629c3e91c95d5dd65b97d91..d0781b313143c2742184ab61f67b2016f6e7b4f6 100644
--- a/pyopencl/scan.py
+++ b/pyopencl/scan.py
@@ -1272,6 +1272,10 @@ class GenericScanKernel(_GenericScanKernelBase):
         if n is None:
             n, = first_array.shape
 
+        if n == 0:
+            # We're done here.
+            return
+
         data_args = []
         from pyopencl.tools import VectorArg
         for arg_descr, arg_val in zip(self.parsed_args, args):