itcl 3.4.3 fails to compile with tcl 8.6.13:
Linux/Opensuse 15.4
itcl 3.4.3 fails to compile with Tcl 8.6.13:
gcc -DPACKAGE_NAME=\"itcl\" -DPACKAGE_TARNAME=\"itcl\" -DPACKAGE_VERSION=\"3.4\" -DPACKAGE_STRING=\"itcl\ 3.4\" -DPACKAGE_BUGREPORT=\"\" -DPACKAGE_URL=\"\" -DBUILD_itcl=/\*\*/ -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DHAVE_LIMITS_H=1 -DHAVE_SYS_PARAM_H=1 -DTCL_THREADS=1 -DMODULE_SCOPE=extern\ __attribute__\(\(__visibility__\(\"hidden\"\)\)\) -DHAVE_HIDDEN=1 -DHAVE_CAST_TO_UNION=1 -D_LARGEFILE64_SOURCE=1 -DTCL_WIDE_INT_IS_LONG=1 -DUSE_TCL_STUBS=1 -DITCL_LIBRARY=\"/homes/ralf/tcltk/linux/lib64/itcl3.4\" -I"./generic" -I"/homes/ralf/tcltk/tcl8.6.13/generic" -I"/homes/ralf/tcltk/tcl8.6.13/unix" -pipe -O2 -fomit-frame-pointer -DNDEBUG -Wall -fPIC -c `echo ./generic/itcl_methods.c` -o itcl_methods.o
In file included from /homes/ralf/tcltk/tcl8.6.13/generic/tclPort.h:25:0,
from /homes/ralf/tcltk/tcl8.6.13/generic/tclInt.h:36,
from ./generic/itclInt.h:50,
from ./generic/itcl_methods.c:31:
./generic/itcl_methods.c: In function ‘Itcl_CreateArg’:
./generic/itcl_methods.c:1159:48: error: invalid application of ‘sizeof’ to incomplete type ‘char[]’
(unsigned)(sizeof(CompiledLocal)-sizeof(localPtr->name) + nameLen+1)
^
/homes/ralf/tcltk/tcl8.6.13/generic/tcl.h:2462:36: note: in definition of macro ‘ckalloc’
((void *) Tcl_Alloc((unsigned)(x)))
^
make[1]: *** [Makefile:266: itcl_methods.o] Error 1
This is due to a change in tclInt.h regarding the TCLFLEXARRAY macro, which changed the "name" member of the struct from "name[0]" to "name[]", so one can no longer take sizeof(name).
Fix: use same allocation code as rest of TCL:
diff -u itcl3.4.3/generic/itcl_methods.c\~ itcl3.4.3/generic/itcl_methods.c
--- itcl3.4.3/generic/itcl_methods.c~ 2015-12-10 19:49:44.000000000 +0100
+++ itcl3.4.3/generic/itcl_methods.c 2022-11-17 13:10:47.930940615 +0100
@@ -1156,7 +1156,7 @@
nameLen = strlen(name);
localPtr = (CompiledLocal*)ckalloc(
- (unsigned)(sizeof(CompiledLocal)-sizeof(localPtr->name) + nameLen+1)
+ TclOffset(CompiledLocal, name) + nameLen+1
);
localPtr->nextPtr = NULL;
Diff finished. Thu Nov 17 13:10:57 2022