diff --git a/pyopencl/array.py b/pyopencl/array.py index 6679387d81bcc031a57992dd2dd9febe4b972e9c..744dca10ab6898abb29545e665c686e850b82d97 100644 --- a/pyopencl/array.py +++ b/pyopencl/array.py @@ -481,9 +481,14 @@ class Array(object): self.allocator = allocator if data is None: - if not alloc_nbytes: - # Work around CL not allowing zero-sized buffers. - alloc_nbytes = 1 + if alloc_nbytes <= 0: + if alloc_nbytes == 0: + # Work around CL not allowing zero-sized buffers. + alloc_nbytes = 1 + + else: + raise ValueError("cannot allocate CL buffer with " + "negative size") if allocator is None: if context is None and queue is not None: