From bb2a2065080a3099eb0dc82d1df0891ad2601316 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Sat, 24 Nov 2018 00:31:40 -0500 Subject: [PATCH] Assert that item-type of arrays have static size --- src/hb-dsalgs.hh | 2 ++ src/hb-open-type.hh | 4 ++++ src/hb-vector.hh | 2 ++ 3 files changed, 8 insertions(+) diff --git a/src/hb-dsalgs.hh b/src/hb-dsalgs.hh index da8aad013..c133a532d 100644 --- a/src/hb-dsalgs.hh +++ b/src/hb-dsalgs.hh @@ -562,6 +562,8 @@ struct hb_bytes_t template struct hb_array_t { + static_assert ((bool) (unsigned) hb_static_size (Type), ""); + inline hb_array_t (void) : arrayZ (nullptr), len (0) {} inline hb_array_t (Type *array_, unsigned int len_) : arrayZ (array_), len (len_) {} diff --git a/src/hb-open-type.hh b/src/hb-open-type.hh index 17bc9c5b4..1c7b738be 100644 --- a/src/hb-open-type.hh +++ b/src/hb-open-type.hh @@ -345,6 +345,8 @@ static inline Type& operator + (Base &base, OffsetTo template struct UnsizedArrayOf { + static_assert ((bool) (unsigned) hb_static_size (Type), ""); + enum { item_size = Type::static_size }; HB_NO_CREATE_COPY_ASSIGN_TEMPLATE (UnsizedArrayOf, Type); @@ -449,6 +451,8 @@ struct UnsizedOffsetListOf : UnsizedOffsetArrayOf template struct ArrayOf { + static_assert ((bool) (unsigned) hb_static_size (Type), ""); + enum { item_size = Type::static_size }; HB_NO_CREATE_COPY_ASSIGN_TEMPLATE2 (ArrayOf, Type, LenType); diff --git a/src/hb-vector.hh b/src/hb-vector.hh index 926f00544..c1d7f946a 100644 --- a/src/hb-vector.hh +++ b/src/hb-vector.hh @@ -34,6 +34,8 @@ template struct hb_vector_t { + static_assert ((bool) (unsigned) hb_static_size (Type), ""); + typedef Type ItemType; enum { item_size = sizeof (Type) };