From baab183439ff4e0c6b77d62156d447e61fc1dcfb Mon Sep 17 00:00:00 2001
From: "Arnold D. Robbins" <arnold@skeeve.com>
Date: Wed, 14 Sep 2022 21:08:59 +0300
Subject: Fix a bug with Node_elem_new.

Reference:https://git.savannah.gnu.org/cgit/gawk.git/patch/?id=baab183439ff4e0c6b77d62156d447e61fc1dcfb
Conflict:tailoring commit on ChangeLog
---
 interpret.h       | 1 +
 test/ChangeLog    | 5 +++++
 test/Makefile.am  | 4 +++-
 test/Makefile.in  | 9 ++++++++-
 test/Maketests    | 5 +++++
 test/elemnew1.awk | 9 +++++++++
 test/elemnew1.ok  | 0
 7 files changed, 31 insertions(+), 2 deletions(-)
 create mode 100644 test/elemnew1.awk
 create mode 100644 test/elemnew1.ok

diff --git a/interpret.h b/interpret.h
index 57d060e..268655b 100644
--- a/interpret.h
+++ b/interpret.h
@@ -238,6 +238,7 @@ uninitialized_scalar:
 						_("reference to uninitialized argument `%s'") :
 						_("reference to uninitialized variable `%s'"),
 								save_symbol->vname);
+				UPREF(m);
 				PUSH(m);
 				break;
 
diff --git a/test/ChangeLog b/test/ChangeLog
index a73637b..ea08ede 100644
--- a/test/ChangeLog
+++ b/test/ChangeLog
@@ -1,3 +1,8 @@
+2022-09-14         Arnold D. Robbins     <arnold@skeeve.com>
+
+	* Makefile.am (EXTRA_DIST): New test: elemnew1.
+	* elemnew1.awk, elemnew1.ok: New files.
+
 2022-09-04         Arnold D. Robbins     <arnold@skeeve.com>
 
 	* 5.2.0: Release tar ball made.
diff --git a/test/Makefile.am b/test/Makefile.am
index ab06974..8a5c3c4 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -282,6 +282,8 @@ EXTRA_DIST = \
 	dumpvars.ok \
 	dynlj.awk \
 	dynlj.ok \
+	elemnew1.awk \
+	elemnew1.ok \
 	escapebrace.awk \
 	escapebrace.in \
 	escapebrace.ok \
@@ -1480,7 +1482,7 @@ GAWK_EXT_TESTS = \
 	binmode1 charasbytes clos1way clos1way2 clos1way3 clos1way4 \
 	clos1way5 clos1way6 colonwarn commas crlf dbugeval dbugeval2 \
 	dbugeval3 dbugtypedre1 dbugtypedre2 delsub devfd devfd1 devfd2 \
-	dfacheck1 dumpvars errno exit fieldwdth forcenum fpat1 fpat2 \
+	dfacheck1 dumpvars elemnew1 errno exit fieldwdth forcenum fpat1 fpat2 \
 	fpat3 fpat4 fpat5 fpat6 fpat7 fpat8 fpat9 fpatnull fsfwfs functab1 \
 	functab2 functab3 functab6 funlen fwtest fwtest2 fwtest3 fwtest4 \
 	fwtest5 fwtest6 fwtest7 fwtest8 genpot gensub gensub2 gensub3 \
diff --git a/test/Makefile.in b/test/Makefile.in
index 834feb0..a4fb1cc 100644
--- a/test/Makefile.in
+++ b/test/Makefile.in
@@ -550,6 +550,8 @@ EXTRA_DIST = \
 	dumpvars.ok \
 	dynlj.awk \
 	dynlj.ok \
+	elemnew1.awk \
+	elemnew1.ok \
 	escapebrace.awk \
 	escapebrace.in \
 	escapebrace.ok \
@@ -1748,7 +1750,7 @@ GAWK_EXT_TESTS = \
 	binmode1 charasbytes clos1way clos1way2 clos1way3 clos1way4 \
 	clos1way5 clos1way6 colonwarn commas crlf dbugeval dbugeval2 \
 	dbugeval3 dbugtypedre1 dbugtypedre2 delsub devfd devfd1 devfd2 \
-	dfacheck1 dumpvars errno exit fieldwdth forcenum fpat1 fpat2 \
+	dfacheck1 dumpvars elemnew1 errno exit fieldwdth forcenum fpat1 fpat2 \
 	fpat3 fpat4 fpat5 fpat6 fpat7 fpat8 fpat9 fpatnull fsfwfs functab1 \
 	functab2 functab3 functab6 funlen fwtest fwtest2 fwtest3 fwtest4 \
 	fwtest5 fwtest6 fwtest7 fwtest8 genpot gensub gensub2 gensub3 \
@@ -4476,6 +4478,11 @@ dfacheck1:
 	@-AWKPATH="$(srcdir)" $(AWK) -f $@.awk  < "$(srcdir)"/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
 	@-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
 
+elemnew1:
+	@echo $@
+	@-AWKPATH="$(srcdir)" $(AWK) -f $@.awk  >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
+	@-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
+
 exit:
 	@echo $@
 	@-$(LOCALES) AWK="$(AWKPROG)" "$(srcdir)"/$@.sh  > _$@ 2>&1 || echo EXIT CODE: $$? >>_$@
diff --git a/test/Maketests b/test/Maketests
index 3a667af..90828e7 100644
--- a/test/Maketests
+++ b/test/Maketests
@@ -1432,6 +1432,11 @@ dfacheck1:
 	@-AWKPATH="$(srcdir)" $(AWK) -f $@.awk  < "$(srcdir)"/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
 	@-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
 
+elemnew1:
+	@echo $@
+	@-AWKPATH="$(srcdir)" $(AWK) -f $@.awk  >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
+	@-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
+
 exit:
 	@echo $@
 	@-$(LOCALES) AWK="$(AWKPROG)" "$(srcdir)"/$@.sh  > _$@ 2>&1 || echo EXIT CODE: $$? >>_$@
diff --git a/test/elemnew1.awk b/test/elemnew1.awk
new file mode 100644
index 0000000..58dc9fc
--- /dev/null
+++ b/test/elemnew1.awk
@@ -0,0 +1,9 @@
+function add_flags(old) {
+  if (old)
+    return 0
+  if (!old)
+    return 1
+}
+BEGIN {
+  a[0]=add_flags(a[0])
+}
diff --git a/test/elemnew1.ok b/test/elemnew1.ok
new file mode 100644
index 0000000..e69de29
-- 
