Tk Source Code

View Ticket
Login
Ticket UUID: ed5c70f73b597425d2ede769128c4b70022eaaee
Title: tk compilation: shadowed local variables
Type: Bug Version: 8.7
Submitter: bll Created on: 2017-05-06 21:16:31
Subsystem: 84. Unix Build Assigned To: nobody
Priority: 5 Medium Severity: Minor
Status: Closed Last Modified: 2026-10-22 17:22:39
Resolution: Fixed Closed By: serhiy.storchaka
    Closed on: 2026-09-25 08:31:15
Description:
Within the 'revised_text' Tk branch, there are 83 warnings about shadowed local variables.  Certainly not all of these are in the revised text changes.

Please see the attached file.

Opinion: A better standard set of gcc/clang compiler flags should be used for development.  For this compilation I used:

-O2 -Wall -Waggregate-return -Wconversion -Wformat -Wmissing-prototypes 
-Wmissing-declarations -Wnested-externs -Wpointer-arith -Wshadow 
-Wstrict-prototypes -Wunused -Wno-unknown-pragmas -Wextra 
-Wno-unused-but-set-variable -Wno-unused-parameter -Wno-float-equal 
-Wformat -Wformat-security -Werror=format-security -D_FORTIFY_SOURCE=2 
-fstack-protector-all 

KBK had some other good warning flags that can be added, which I should have added on also.
(reference: https://groups.google.com/d/msg/tcl-core/tNGaw9ops2Q/igBdyH_YBQAJ ):

-Wall -Wextra -Wshadow -Wcast-qual -Wwrite-strings -Wformat=2 
-Wswitch-default -Wswitch-enum -Wcast-align -Wpointer-arith 
-Wstrict=overflow=2 =Wlogical-op -Wstrict-alising=2 -Wredundant-decls

Note that some of these are included within -Wall and/or -Wextra and are redundant.
User Comments: serhiy.storchaka added on 2026-09-25 08:31:15:

Tk 9.x is built with -Wshadow by default, and main and revised_text now build without shadowing warnings. Closing.


Attachments: