From f1bf5b61d16ef3560e3f5b64c50de559620123f7 Mon Sep 17 00:00:00 2001
From: Rob Latham <robl@mcs.anl.gov>
Date: Tue, 30 Nov 2021 16:06:22 -0600
Subject: [PATCH] Use flexible array notation for te_expr

Newer gcc gets confused when malloc stores a bunch of memory in a
one-element array.  C99 "flexible array" notation achieves the same
effect in a more standard way.
---
 tinyexpr.c | 2 +-
 tinyexpr.h | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/tinyexpr.c b/tinyexpr.c
index bee3cfd..72bcc8f 100755
--- a/tinyexpr.c
+++ b/tinyexpr.c
@@ -86,7 +86,7 @@ typedef struct state {
 static te_expr *new_expr(const int type, const te_expr *parameters[]) {
     const int arity = ARITY(type);
     const int psize = sizeof(void*) * arity;
-    const int size = (sizeof(te_expr) - sizeof(void*)) + psize + (IS_CLOSURE(type) ? sizeof(void*) : 0);
+    const int size = sizeof(te_expr) + psize + (IS_CLOSURE(type) ? sizeof(void*) : 0);
     te_expr *ret = malloc(size);
     memset(ret, 0, size);
     if (arity && parameters) {
diff --git a/tinyexpr.h b/tinyexpr.h
index c2cbe1a..6d3d4b0 100644
--- a/tinyexpr.h
+++ b/tinyexpr.h
@@ -36,7 +36,7 @@ extern "C" {
 typedef struct te_expr {
     int type;
     union {double value; const double *bound; const void *function;};
-    void *parameters[1];
+    void *parameters[];
 } te_expr;