Tcl Source Code

View Ticket
Login
Ticket UUID: 2881263
Title: cannot compile with gcc 2.95.4
Type: Bug Created on: 2009-10-18 12:17:05
Submitter: mistachkin Assigned to: andreas_kupries
Subsystem: 47. Bytecode Compiler Severity:
Priority: 5 Medium Last modified: 2009-10-24 02:31:33
Status: Closed Closed by: andreas_kupries
Resolution: Fixed Closed on: 2009-10-23 19:30:49
Version: obsolete: 8.4.19
Description:
Version 2.95.4 of gcc does not appear to like a variable declaration after an empty statement.  In tclCompCmds.c, there is a macro "DefineLineInformation" that evaluates to an empty statement when the TCL_TIP280 define is not present.  This causes the following compiler errors:

gcc -c -g -pipe -pthread -DTCL_DBGX=g -Wall -fno-strict-aliasing -fPIC -I. -I/tcl/tcl8.4/tcl/unix/../generic -I/tcl/tcl8.4/tcl/unix -DNO_VALUES_H=1 -DHAVE_LIMITS_H=1 -DHAVE_UNISTD_H=1 -DHAVE_SYS_PARAM_H=1 -DUSE_THREAD_ALLOC=1 -D_REENTRANT=1 -D_THREAD_SAFE=1 -DHAVE_PTHREAD_ATTR_SETSTACKSIZE=1 -DTCL_THREADS=1 -DTCL_MEM_DEBUG=1 -DTCL_COMPILE_DEBUG=1 -DTCL_COMPILE_STATS=1 -DTCL_WIDE_INT_TYPE=long\ long -DHAVE_GETCWD=1 -DHAVE_OPENDIR=1 -DHAVE_STRSTR=1 -DHAVE_STRTOL=1 -DHAVE_STRTOLL=1 -DHAVE_STRTOULL=1 -DHAVE_TMPNAM=1 -DHAVE_WAITPID=1 -DUSE_TERMIOS=1 -DHAVE_SYS_TIME_H=1 -DTIME_WITH_SYS_TIME=1 -DHAVE_TM_ZONE=1 -DHAVE_GMTIME_R=1 -DHAVE_LOCALTIME_R=1 -DHAVE_TM_GMTOFF=1 -DHAVE_ST_BLKSIZE=1 -DSTDC_HEADERS=1 -DHAVE_SIGNED_CHAR=1 -DHAVE_PUTENV_THAT_COPIES=1 -DHAVE_LANGINFO=1 -DHAVE_FTS=1 -DHAVE_SYS_IOCTL_H=1 -DHAVE_SYS_FILIO_H=1 -DTCL_SHLIB_EXT=\".so\" /tcl/tcl8.4/tcl/unix/../generic/tclCompCmds.c

/tcl/tcl8.4/tcl/unix/../generic/tclCompCmds.c: In function `TclCompileForeachCmd':
/tcl/tcl8.4/tcl/unix/../generic/tclCompCmds.c:784: syntax error before `int'
/tcl/tcl8.4/tcl/unix/../generic/tclCompCmds.c:828: `varcList' undeclared (first use in this function)
/tcl/tcl8.4/tcl/unix/../generic/tclCompCmds.c:828: (Each undeclared identifier is reported only once
/tcl/tcl8.4/tcl/unix/../generic/tclCompCmds.c:828: for each function it appears in.)
/tcl/tcl8.4/tcl/unix/../generic/tclCompCmds.c:829: `varvList' undeclared (first use in this function)
/tcl/tcl8.4/tcl/unix/../generic/tclCompCmds.c:1078: `varcListStaticSpace' undeclared (first use in this function)
/tcl/tcl8.4/tcl/unix/../generic/tclCompCmds.c: In function `TclCompileLindexCmd':
/tcl/tcl8.4/tcl/unix/../generic/tclCompCmds.c:1857: syntax error before `int'
/tcl/tcl8.4/tcl/unix/../generic/tclCompCmds.c:1858: `numWords' undeclared (first use in this function) 

I believe it is important to continue to support this particular compiler version with Tcl 8.4 for the following reasons:

1. Historically, it has always worked with 8.4.
2. It works with HEAD and the latest code on core-8-5-branch.
3. It should be fairly trivial to change the code in tclCompCmds.c to avoid using the problematic construct.
User Comments:
dgp added on 2009-10-20 03:39:35:
agreed. please commit fix to the core-8-4-branch.

andreas_kupries added on 2009-10-20 03:48:54:
Assigning to maintainer of the #280 code.
Joe, if you have a patch, please attach to the bug report.

2 Possibilities:

(1) Redefine DefineLineInformation (DFL) to contain the semicolon when #280 is active. Then we can remove the semicolon from all uses of DFL, killing it completely when building without #280, instead of leaving an empty statement.

(2) Keep the definitions as is and move the uses of DFL after the last variable decl in each block, so that the empty statement comes after the var decls and not in between.

Opinions ?

dgp added on 2009-10-20 04:50:54:
weak preference for (2).

andreas_kupries added on 2009-10-24 02:30:49:

allow_comments - 1

Fixed in 8.4 branch head. Two places needed fixes, TclCompileForeachCmd,
and TclCompileLindexCmd. This also affected MSVC6, per patthoyts, on the chat.

andreas_kupries added on 2009-10-24 02:31:33:
Oh, and I went with option (2), moving the uses to proper location. Only two had been wrong.