diff --git i/src/backend/utils/adt/jsonpath_exec.c w/src/backend/utils/adt/jsonpath_exec.c
index 2191d67bfc0..ee24f0aa9b9 100644
--- i/src/backend/utils/adt/jsonpath_exec.c
+++ w/src/backend/utils/adt/jsonpath_exec.c
@@ -174,7 +174,21 @@ typedef struct JsonValueList
 	int			maxitems;		/* allocated length of items[] */
 	struct JsonValueList *next; /* => next chunk, if any */
 	struct JsonValueList *last; /* => last chunk (only valid in base chunk) */
-	JsonbValue	items[BASE_JVL_ITEMS];
+	union
+	{
+		/*
+		 * To satisfy -fstrict-flex-arrays=1, we need one union member that
+		 * makes space for the base chunk and one member that is effectively
+		 * declared as a flexible-array member, otherwise you'd get
+		 * -fsanitize=undefined errors.  Note that we can't declare items as
+		 * [FLEXIBLE_ARRAY_MEMBER], because JsonValueList is used in a
+		 * non-last field of JsonTablePlanState, and that's not allowed with
+		 * flexible-array members.  But using [1] works as long as we don't go
+		 * higher than -fstrict-flex-arrays=1.
+		 */
+		JsonbValue	base_items[BASE_JVL_ITEMS];
+		JsonbValue	items[1] pg_attribute_strict_flex_array(1);
+	};
 } JsonValueList;
 
 /* State data for iterating through a JsonValueList */
diff --git i/src/include/c.h w/src/include/c.h
index 95e71d7e612..e66898427f4 100644
--- i/src/include/c.h
+++ w/src/include/c.h
@@ -316,6 +316,23 @@ extern "C++"
 #define pg_attribute_target(...)
 #endif
 
+/*
+ * pg_attribute_strict_flex_array allows specifying the level of strictness for
+ * an individual flexible array member. For instance, most of the time we should
+ * use FLEXIBLE_ARRAY_MEMBER when defining flexible arrays in structs, but
+ * sometimes those structs are embedded within other structs that may not allow
+ * us to do that. pg_attribute_strict_flex_array is a backdoor to lessen
+ * strictness for the singular member such that we can define a flexible array
+ * member using other idioms.
+ *
+ * Currently only available on GCC 15+.
+ */
+#if __has_attribute (strict_flex_array)
+#define pg_attribute_strict_flex_array(level) __attribute__((strict_flex_array(level)))
+#else
+#define pg_attribute_strict_flex_array(level)
+#endif
+
 /*
  * pg_attribute_counted_by specifies that a flexible array member is "counted
  * by" another struct member.  This allows the compiler to improve detection
