Thanks for reporting that. tcc is failing because it claims to support C99 (it defines __STDC_VERSION__ to 199901L), but it doesn't support variable length arrays as C99 requires. Perhaps you could file a bug report with the tcc folks? A simple fix would be for tcc to predefine __STDC_NO_VLA__ to 1.

Anyway, I installed the attached patches into Gnulib to attempt to work around the tcc bug. The first patch should fix regex.c; the second one should fix gettext.h to behave like regex.c does; the third tries to document this messy area better.
From f00090baf8f31644d9da9a99548548fab8b710ec Mon Sep 17 00:00:00 2001
From: Paul Eggert <egg...@cs.ucla.edu>
Date: Sat, 27 Nov 2021 00:00:46 -0800
Subject: [PATCH 1/3] regex: port to tcc

Problem reported by Benno Schulenberg in:
https://lists.gnu.org/r/bug-gnulib/2021-11/msg00038.html
* modules/regex (Depends-on): Depend on vararrays, since
lib/regex.h uses __STDC_NO_VLA__.
* modules/vararrays: Change license from LGPL to LGPLv2+.
---
 ChangeLog         | 9 +++++++++
 modules/regex     | 1 +
 modules/vararrays | 2 +-
 3 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index efbe6c888..d2e7cc596 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2021-11-27  Paul Eggert  <egg...@cs.ucla.edu>
+
+	regex: port to tcc
+	Problem reported by Benno Schulenberg in:
+	https://lists.gnu.org/r/bug-gnulib/2021-11/msg00038.html
+	* modules/regex (Depends-on): Depend on vararrays, since
+	lib/regex.h uses __STDC_NO_VLA__.
+	* modules/vararrays: Change license from LGPL to LGPLv2+.
+
 2021-11-25  Bernhard Voelker  <m...@bernhard-voelker.de>
 
 	test-framework-sh: remove unsafe entries from PATH
diff --git a/modules/regex b/modules/regex
index 866ade60c..352c0aaa2 100644
--- a/modules/regex
+++ b/modules/regex
@@ -16,6 +16,7 @@ Depends-on:
 c99
 extensions
 ssize_t
+vararrays
 attribute       [test $ac_use_included_regex = yes]
 btowc           [test $ac_use_included_regex = yes]
 builtin-expect  [test $ac_use_included_regex = yes]
diff --git a/modules/vararrays b/modules/vararrays
index 335fe46e8..6a7df9a8a 100644
--- a/modules/vararrays
+++ b/modules/vararrays
@@ -14,7 +14,7 @@ Makefile.am:
 Include:
 
 License:
-LGPL
+LGPLv2+
 
 Maintainer:
 Paul Eggert
-- 
2.32.0

From 5750a04d7ae9fd637864092b6eb1153a225d0e36 Mon Sep 17 00:00:00 2001
From: Paul Eggert <egg...@cs.ucla.edu>
Date: Sat, 27 Nov 2021 00:33:24 -0800
Subject: [PATCH 2/3] gettext-h: use VLA test similar to regex

* lib/gettext.h (_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS): Assuming
GNULIB_NO_VLA, define if (defined __STDC_VERSION__ && 199901L <=
__STDC_VERSION__ \ + && !defined __STDC_NO_VLA___), not if
((__GNUC__ >= 3 || __GNUG__ >= 2) && !defined __STRICT_ANSI__).
This is more consistent with what the regex module does.
* modules/gettext-h (Depends-on): Depend on vararrays, since
lib/gettext.h uses __STDC_NO_VLA__.
---
 ChangeLog         | 9 +++++++++
 lib/gettext.h     | 5 ++---
 modules/gettext-h | 1 +
 3 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index d2e7cc596..66c53a923 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,14 @@
 2021-11-27  Paul Eggert  <egg...@cs.ucla.edu>
 
+	gettext-h: use VLA test similar to regex
+	* lib/gettext.h (_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS): Assuming
+	GNULIB_NO_VLA, define if (defined __STDC_VERSION__ && 199901L <=
+	__STDC_VERSION__ \ + && !defined __STDC_NO_VLA___), not if
+	((__GNUC__ >= 3 || __GNUG__ >= 2) && !defined __STRICT_ANSI__).
+	This is more consistent with what the regex module does.
+	* modules/gettext-h (Depends-on): Depend on vararrays, since
+	lib/gettext.h uses __STDC_NO_VLA__.
+
 	regex: port to tcc
 	Problem reported by Benno Schulenberg in:
 	https://lists.gnu.org/r/bug-gnulib/2021-11/msg00038.html
diff --git a/lib/gettext.h b/lib/gettext.h
index f1c7a2407..01d9c1cf6 100644
--- a/lib/gettext.h
+++ b/lib/gettext.h
@@ -191,9 +191,8 @@ npgettext_aux (const char *domain,
    or may have security implications due to non-deterministic stack usage.  */
 
 #if (!defined GNULIB_NO_VLA \
-     && (((__GNUC__ >= 3 || __GNUG__ >= 2) && !defined __STRICT_ANSI__) \
-     /*  || (__STDC_VERSION__ == 199901L && !defined __HP_cc)
-         || (__STDC_VERSION__ >= 201112L && !defined __STDC_NO_VLA__) */ ))
+     && defined __STDC_VERSION__ && 199901L <= __STDC_VERSION__ \
+     && !defined __STDC_NO_VLA__)
 # define _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS 1
 #else
 # define _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS 0
diff --git a/modules/gettext-h b/modules/gettext-h
index 72bdcb284..a0036d09c 100644
--- a/modules/gettext-h
+++ b/modules/gettext-h
@@ -5,6 +5,7 @@ Files:
 lib/gettext.h
 
 Depends-on:
+vararrays
 
 configure.ac:
 AC_SUBST([LIBINTL])
-- 
2.32.0

From 93d6b015747f5fc4592f22535579480b8828461c Mon Sep 17 00:00:00 2001
From: Paul Eggert <egg...@cs.ucla.edu>
Date: Sat, 27 Nov 2021 00:49:56 -0800
Subject: [PATCH 3/3] gettext-h: document GNULIB_NO_VLA

* doc/gnulib-readme.texi (C99 features avoided):
Document GNULIB_NO_VLA.
---
 ChangeLog              |  4 ++++
 doc/gnulib-readme.texi | 15 +++++++++++++--
 2 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 66c53a923..efc289fa6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
 2021-11-27  Paul Eggert  <egg...@cs.ucla.edu>
 
+	gettext-h: document GNULIB_NO_VLA
+	* doc/gnulib-readme.texi (C99 features avoided):
+	Document GNULIB_NO_VLA.
+
 	gettext-h: use VLA test similar to regex
 	* lib/gettext.h (_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS): Assuming
 	GNULIB_NO_VLA, define if (defined __STDC_VERSION__ && 199901L <=
diff --git a/doc/gnulib-readme.texi b/doc/gnulib-readme.texi
index 0a32f980c..9f9e1c1ce 100644
--- a/doc/gnulib-readme.texi
+++ b/doc/gnulib-readme.texi
@@ -402,8 +402,19 @@ feature should require the corresponding module.
 
 @itemize
 @item
-Variable length arrays, unless @code{__STDC_NO_VLA__} is defined.
-See the @code{vararrays} module.
+Variable length arrays (VLAs) or variably modified types,
+without checking whether @code{__STDC_NO_VLA__} is defined.
+See the @code{vararrays} and @code{vla} modules.
+
+@item
+Block-scope variable length arrays, without checking whether either
+@code{GNULIB_NO_VLA} or @code{__STDC_NO_VLA__} is defined.
+This lets you define @code{GNULIB_NO_VLA} to pacify GCC when
+using its @option{-Wvla-larger-than warnings} option,
+and to avoid large stack usage that may have security implications.
+@code{GNULIB_NO_VLA} does not affect Gnulib's other uses of VLAs and
+variably modified types, such as array declarations in function
+prototype scope.
 
 @item
 @code{extern inline} functions, without checking whether they are
-- 
2.32.0

Reply via email to