Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: PATCH: compstate[nmatches]



In article <199910130946.LAA12312@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>,
  Sven Wischnowsky <wischnow@xxxxxxxxxxxxxxxxxxxxxxx> writes:

> -static int nmatches, smatches;
> +/**/
> +int nmatches, smatches;

>      VARARR(int, mlens, nmatches + 1);

This change tickle a gcc bug.

% gcc -c -I. -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -DHAVE_CONFIG_H -DMODULE -Wall -Wno-implicit -Wmissing-prototypes -ggdb -fpic -o zle_tricky..o zle_tricky.c
zle_tricky.c: In function `calclist':
zle_tricky.c:8804: size of array `mlens' is too large
zle_tricky.c:8804: warning: unused variable `mlens'
zsh: exit 1     gcc -DHAVE_VARIABLE_LENGTH_ARRAYS -c -I. -D_LARGEFILE_SOURCE  -DHAVE_CONFIG_H

It is reproducible with more simple program as:

Z(2):akr@is27e1u11% cat tst.c
int num;

void fun(void)
{
  int arr[num + 1];
}
Z(2):akr@is27e1u11% gcc -c tst.c
tst.c: In function `fun':
tst.c:5: size of array `arr' is too large
zsh: exit 1     gcc -c tst.c

At least, gcc-2.8.1 and 2.95.1 has the problem.
But gcc-2.7.2.3 has no problem.

Although I sent a bug report to gcc developpers, zsh should check it.

Index: configure.in
===================================================================
RCS file: /projects/zsh/zsh/configure.in,v
retrieving revision 1.1.1.28
diff -u -F^( -r1.1.1.28 configure.in
--- configure.in	1999/10/06 19:45:06	1.1.1.28
+++ configure.in	1999/10/13 18:53:55
@@ -367,7 +367,7 @@
 dnl Checking if the compiler supports variable-length arrays
 AC_CACHE_CHECK(if the compiler supports variable-length arrays,
 zsh_cv_c_variable_length_arrays,
-[AC_TRY_COMPILE([int foo();], [int i[foo()];],
+[AC_TRY_COMPILE([int foo(), n;], [int i[foo()], a[n+1];],
   zsh_cv_c_variable_length_arrays=yes,
   zsh_cv_c_variable_length_arrays=no)])
 if test $zsh_cv_c_variable_length_arrays = yes; then
-- 
Tanaka Akira



Messages sorted by: Reverse Date, Date, Thread, Author