Tcl Source Code

View Ticket
Login
Ticket UUID: 1615c806389ed4e58b4091714c8503cccabf49e4
Title: gcc warnings compiling in 32-bit mode
Type: Bug Created on: 2025-06-04 04:42:23
Submitter: apnadkarni Assigned to: dkf
Subsystem: - New Builtin Commands Severity: Cosmetic
Priority: 3 Low Last modified: 2026-05-02 06:39:59
Status: Closed Closed by: apnadkarni
Resolution: Fixed Closed on: 2026-05-02 06:39:59
Version: 9.0.2
Description:

gcc spits out a bunch of warnings similar to below for compiling for 32-bit architectures:

C:/src/tcltk/wip/tcl/generic/tclCompCmds.c: In function 'TclCompileAppendCmd':
C:/src/tcltk/wip/tcl/generic/tclCompCmds.c:144:35: warning: comparison of integer expressions of different signedness: 'Tcl_Size' {aka 'int'} and 'unsigned int' [-Wsign-compare]
  144 |     if (numWords == 1 || numWords > UINT_MAX) {

The comparison does not make sense on 32-bit archs as the expression will never be true. More important, the number of warnings output means potentially serious warnings are missed.

User Comments:
chrstphrchvz added on 2025-12-05 03:15:51:

I believe the version for this ticket should be 9.1. I don't think 9.0 or earlier are affected.


jan.nijtmans added on 2025-12-08 15:08:26:

Those changes were introduced with [507b920e63397514|this] commit (TIP 720: Bytecode generation improvements/sanity).

Therefore, assigning to @dkf


cdubois added on 2026-01-06 04:20:23:
Thanks for the pointers regarding TIP 720.

I’ll try to reproduce the -Wsign-compare warnings in a true 32-bit build (either an i386 container or a multilib -m32 build). I’ll report back with the exact gcc version/flags and whether this reproduces on 9.0.2 vs current development (9.1/trunk).

If confirmed, I can propose a patch to make the comparisons type-safe and verify it by rebuilding (and running relevant tests) on 32-bit.

stu added on 2026-03-13 10:47:13:
In 9.1a1: 43 warnings like this, in:
generic/tclCompCmds.c
generic/tclCompCmdsGR.c
generic/tclCompCmdsSZ.c

dkf added on 2026-04-30 16:06:49:

Ought to be resolved, or at least fewer error messages (max one per compiled file). Done by moving the comparison to a static inline function in tclCompile.h; if my implementation in there isn't right, fix it in that one place.

Works for me now.


jan.nijtmans added on 2026-05-01 16:00:58:

Well, 9.1 build is broken now, even worse at it was:

https://github.com/tcltk/tcl/actions/runs/25206800733

Tests ended at 2026-05-01 07:53:02 UTC
all.tcl:	Total	481605	Passed	475243	Skipped	6295	Failed	67
Sourced 173 Test Files.
Files with failing tests: compExpr.test coroutine.test dict.test info.test interp.test lmap.test mathop.test nre.test oo.test regexpComp.test stack.test trace.test

Re-opening


apnadkarni added on 2026-05-02 06:20:43:
Failures also present on 32-bit Windows. As an aside, I'm a bit surprised GH CI does not include Windows 32-bit config.

apnadkarni added on 2026-05-02 06:39:48:
Fixed in [5ae9991e]. Verified on mingw32, vc++ 32 and gcc 64.