summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--include/stc/cspan.h3
1 files changed, 2 insertions, 1 deletions
diff --git a/include/stc/cspan.h b/include/stc/cspan.h
index af76ea63..a4c8f5cb 100644
--- a/include/stc/cspan.h
+++ b/include/stc/cspan.h
@@ -67,7 +67,8 @@ int demo2() {
typedef struct { Self##_value *data; uint32_t dim[RANK]; } Self; \
\
STC_INLINE Self##_iter Self##_begin(const Self* self) { \
- Self##_iter it = {self->data, self->data + cspan_size(self)}; \
+ size_t n = cspan_size(self); \
+ Self##_iter it = {n ? self->data : NULL, self->data + n}; \
return it; \
} \
STC_INLINE Self##_iter Self##_end(const Self* self) { \