From 290487b03ed7a9fa78af6faa2d8c19f7e5fde30e Mon Sep 17 00:00:00 2001 From: "A. Unique TensorFlower" Date: Thu, 28 May 2020 09:18:29 -0700 Subject: [PATCH] Fix for build errors with constexpr TfLiteIntArray. PiperOrigin-RevId: 313599824 Change-Id: Ia37465dd2f782e234839bdfbe991516d9fc06c40 --- tensorflow/lite/micro/micro_allocator.cc | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/tensorflow/lite/micro/micro_allocator.cc b/tensorflow/lite/micro/micro_allocator.cc index c4f7f859e99..d43f0ec076f 100644 --- a/tensorflow/lite/micro/micro_allocator.cc +++ b/tensorflow/lite/micro/micro_allocator.cc @@ -46,9 +46,14 @@ struct AllocationInfo { // requirement for SIMD extensions. constexpr int kBufferAlignment = 16; -// Static instance of a zero-length int to pass as tensor dims for a flatbuffer -// Tensor with no shape. -constexpr TfLiteIntArray kZeroLengthIntArray = {0, {}}; +// Instance of a zero-length int to pass as tensor dims for a flatbuffer +// Tensor with no shape. Note that the second member of a TfLiteArray is a +// flexible array member, which is not strictly valid C++. However it is +// supported by both GCC and clang, as long as the flexible array element is not +// initialized, which is ok in this case as it should never be accessed. +// Declaring this as constexpr causes build errors with clang, as it requires +// the flexible array element to be initialized. +const TfLiteIntArray kZeroLengthIntArray = {0}; class MicroBuiltinDataAllocator : public BuiltinDataAllocator { public: