From a9088e532b482afa7c8a25ffda071e20172a36fe Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Sat, 20 May 2017 07:30:27 -0700 Subject: ffi: diagnose carray of incomplete type. * ffi.c (carray_buf): Do not allow an element type with zero size; throw an exception. --- ffi.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ffi.c b/ffi.c index c8819faf..6dfd663c 100644 --- a/ffi.c +++ b/ffi.c @@ -2612,6 +2612,10 @@ val carray_buf(val buf, val type) cnum blen = c_num(length_buf(buf)); struct txr_ffi_type *tft = ffi_type_struct(type); cnum nelem = if3(tft->size, blen / tft->size, 0); + if (tft->size == 0) + uw_throwf(error_s, + lit("~a: incomplete type ~s cannot be carray element"), + self, tft->syntax, nao); return make_carray(type, data, nelem, buf); } -- cgit v1.2.3