1diff --git a/include/flatbuffers/base.h b/include/flatbuffers/base.h 2index 8e97c08..6f3fea5 100644 3--- a/include/flatbuffers/base.h 4+++ b/include/flatbuffers/base.h 5@@ -1,6 +1,16 @@ 6 #ifndef FLATBUFFERS_BASE_H_ 7 #define FLATBUFFERS_BASE_H_ 8 9+// For TFLM, we always want FLATBUFFERS_LOCALE_INDEPENDENT to be defined as 0. 10+// We could achieve this by adding -DFLATBUFFERS_LOCALE_INDEPENDENT=0 to the 11+// TFLM Makefile. However, for (at least) the Arduino, adding additional build 12+// flags during the compilation can be a bit awkward. As such, we have instead 13+// made a decision to change the default to be FLATBUFFERS_LOCALE_INDEPENDENT=0 14+// for TFLM to make it easier for external IDE integration. 15+#ifndef FLATBUFFERS_LOCALE_INDEPENDENT 16+#define FLATBUFFERS_LOCALE_INDEPENDENT 0 17+#endif 18+ 19 // clang-format off 20 21 // If activate should be declared and included first. 22diff --git a/include/flatbuffers/flexbuffers.h b/include/flatbuffers/flexbuffers.h 23index a45d14b..a4401f8 100644 24--- a/include/flatbuffers/flexbuffers.h 25+++ b/include/flatbuffers/flexbuffers.h 26@@ -493,9 +493,19 @@ class Reference { 27 return static_cast<double>(ReadUInt64(Indirect(), byte_width_)); 28 case FBT_NULL: return 0.0; 29 case FBT_STRING: { 30+#if 1 31+#pragma GCC diagnostic push 32+#pragma GCC diagnostic ignored "-Wnull-dereference" 33+ // TODO(b/173239141): Patched via micro/tools/make/flexbuffers_download.sh 34+ // Introduce a segfault for an unsupported code path for TFLM. 35+ return *(static_cast<double*>(nullptr)); 36+#pragma GCC diagnostic pop 37+#else 38+ // This is the original code 39 double d; 40 flatbuffers::StringToNumber(AsString().c_str(), &d); 41 return d; 42+#endif 43 } 44 case FBT_VECTOR: return static_cast<double>(AsVector().size()); 45 case FBT_BOOL: 46