From 43fb253b75a3c76977317a111798c7be512bd032 Mon Sep 17 00:00:00 2001 From: Tyge Løvset Date: Wed, 18 Jan 2023 11:33:56 +0100 Subject: fix bug in cspan_begin(). --- include/stc/cspan.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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) { \ -- cgit v1.2.3