GeezerVison is showing github.com — Unreachable code warnings while building latest main at 48c70b8 · Issue #128086 · python/cpython
Unreachable code warnings while building latest main at 48c70b8 #128086Labels buildThe build process and cross-buildThe build process and cross-buildinterpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)pendingThe issue will be closed if no feedback is providedThe issue will be closed if no feedback is providedtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error DescriptionBug report
Bug description:
I ran the ./configure and make, here are the warnings shown.
gcc -c -fno-strict-overflow -Wsign-compare -Wunreachable-code -DNDEBUG -g -O3 -Wall -std=c11 -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -Wstrict-prototypes -Werror=implicit-function-declaration -fvisibility=hidden -I./Include/internal -I./Include/internal/mimalloc -I. -I./Include -DPy_BUILD_CORE -o Python/ast.o Python/ast.c
gcc -c -fno-strict-overflow -Wsign-compare -Wunreachable-code -DNDEBUG -g -O3 -Wall -std=c11 -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -Wstrict-prototypes -Werror=implicit-function-declaration -fvisibility=hidden -I./Include/internal -I./Include/internal/mimalloc -I. -I./Include -DPy_BUILD_CORE -o Python/ast_opt.o Python/ast_opt.c
gcc -c -fno-strict-overflow -Wsign-compare -Wunreachable-code -DNDEBUG -g -O3 -Wall -std=c11 -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -Wstrict-prototypes -Werror=implicit-function-declaration -fvisibility=hidden -I./Include/internal -I./Include/internal/mimalloc -I. -I./Include -DPy_BUILD_CORE -o Python/ast_unparse.o Python/ast_unparse.c
gcc -c -fno-strict-overflow -Wsign-compare -Wunreachable-code -DNDEBUG -g -O3 -Wall -std=c11 -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -Wstrict-prototypes -Werror=implicit-function-declaration -fvisibility=hidden -I./Include/internal -I./Include/internal/mimalloc -I. -I./Include -DPy_BUILD_CORE -o Python/bltinmodule.o Python/bltinmodule.c
gcc -c -fno-strict-overflow -Wsign-compare -Wunreachable-code -DNDEBUG -g -O3 -Wall -std=c11 -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -Wstrict-prototypes -Werror=implicit-function-declaration -fvisibility=hidden -I./Include/internal -I./Include/internal/mimalloc -I. -I./Include -DPy_BUILD_CORE -o Python/brc.o Python/brc.c
gcc -c -fno-strict-overflow -Wsign-compare -Wunreachable-code -DNDEBUG -g -O3 -Wall -std=c11 -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -Wstrict-prototypes -Werror=implicit-function-declaration -fvisibility=hidden -I./Include/internal -I./Include/internal/mimalloc -I. -I./Include -DPy_BUILD_CORE -o Python/ceval.o Python/ceval.c
In file included from Python/ceval.c:904:
Python/generated_cases.c.h:808:31: warning: code will never be executed [-Wunreachable-code]
808 | for (int _i = oparg; --_i >= 0;) {
| ^~~~~
Python/generated_cases.c.h:694:31: warning: code will never be executed [-Wunreachable-code]
694 | for (int _i = oparg*2; --_i >= 0;) {
| ^~~~~
2 warnings generated.
Operating System:
➜ cpython git:(main) uname -a
Darwin SREDDY- 24.1.0 Darwin Kernel Version 24.1.0: Thu Oct 10 21:02:27 PDT 2024; root:xnu-11215.41.3~2/RELEASE_X86_64 x86_64
Main branch commit : 48c70b8
CPython versions tested on:
CPython main branch
Operating systems tested on:
macOS Activitychanged the title [-]Warnings while building latest main [/-] [+]Unreachable code warnings while building latest main at 48c70b8[/+] on Dec 19, 2024srinivasreddy commented on Dec 19, 2024 ContributorAuthor More actions I have updated the tcl-tk to version 9.0.0_1, the warnings are gone. Please refer - build.log erlend-aasland commented on Jan 3, 2025 I cannot reproduce this on my MacBook. The tcl-tk comment seems off-topic for this issue. Can you provide more information about your environment? srinivasreddy commented on Jan 3, 2025 ContributorAuthor More actions Like gcc compiler version? and ...? erlend-aasland commented on Jan 3, 2025 Include everything that is needed to reproduce the failure you are seeing. Are you still seeing these failures? Did you compile from a clean source tree (git clean -fdx)? srinivasreddy commented on Jan 3, 2025 ContributorAuthor More actions ➜ cpython git:(main) env
TERM_SESSION_ID=REDACTED
SSH_AUTH_SOCK=/private/tmp/com.apple.launchd.xFPWqTHwrg/Listeners
LC_TERMINAL_VERSION=3.5.10
COLORFGBG=7;0
ITERM_PROFILE=REDACTED
XPC_FLAGS=0x0
LANG=en_US.UTF-8
PWD=/Users/REDACTED/workspace/github_repos/cpython
SHELL=/bin/zsh
__CFBundleIdentifier=com.googlecode.iterm2
TERM_FEATURES=REDACTED
TERM_PROGRAM_VERSION=3.5.10
TERM_PROGRAM=iTerm.app
PATH=/Users/REDACTED/.nvm/versions/node/v20.17.0/bin:/Library/Frameworks/Python.framework/Versions/3.8/bin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/Library/Apple/usr/bin:/Users/REDACTED/.cargo/bin:/Applications/iTerm.app/Contents/Resources/utilities:/Users/REDACTED/.local/bin
LC_TERMINAL=iTerm2
COLORTERM=truecolor
COMMAND_MODE=unix2003
TERM=xterm-256color
TERMINFO_DIRS=/Applications/iTerm.app/Contents/Resources/terminfo:/usr/share/terminfo
HOME=/Users/REDACTED
TMPDIR=/var/folders/6v/n8nm5d6136b0br85j6llcy3c0000gn/T/
USER=REDACTED
XPC_SERVICE_NAME=0
LOGNAME=REDACTED
ITERM_SESSION_ID=REDACTED
__CF_USER_TEXT_ENCODING=0x0:0:0
SHLVL=1
OLDPWD=/Users/REDACTED/workspace/github_repos
ZSH=/Users/REDACTED/.oh-my-zsh
PAGER=less
LESS=-R
LSCOLORS=Gxfxcxdxbxegedabagacad
NVM_DIR=/Users/REDACTED/.nvm
NVM_CD_FLAGS=-q
NVM_BIN=/Users/REDACTED/.nvm/versions/node/v20.17.0/bin
NVM_INC=/Users/REDACTED/.nvm/versions/node/v20.17.0/include/node
LC_ALL=en_US.UTF-8
_=/usr/bin/env
➜ cpython git:(main) sw_vers
ProductName: macOS
ProductVersion: 15.1.1
BuildVersion: 24B91
➜ cpython git:(main) gcc --version
Apple clang version 16.0.0 (clang-1600.0.26.6)
Target: x86_64-apple-darwin24.1.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
➜ cpython git:(main) xcodebuild -version
Xcode 16.2
Build version 16C5032a
➜ cpython git:(main) clang --version
Apple clang version 16.0.0 (clang-1600.0.26.6)
Target: x86_64-apple-darwin24.1.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
erlend-aasland commented on Jan 3, 2025 Still unable to reproduce. I'm on the same macOS version and the same compiler. srinivasreddy commented on Jan 3, 2025 ContributorAuthor More actions Here is the ./configure output i have captured.
config.log srinivasreddy commented on Jan 3, 2025 ContributorAuthor More actions Here is the make output i have capture with the command - make &> make.log. You should be able to see the warnings in the make.log file.
make.log
In file included from Python/ceval.c:904:
Python/generated_cases.c.h:808:31: warning: code will never be executed [-Wunreachable-code]
808 | for (int _i = oparg; --_i >= 0;) {
| ^~~~~
Python/generated_cases.c.h:694:31: warning: code will never be executed [-Wunreachable-code]
694 | for (int _i = oparg*2; --_i >= 0;) {
| ^~~~~
2 warnings generated.
Main branch at b4f799b picnixz commented on Jan 3, 2025 Try to also do a make distclean, make clean and make cleantest. Some files might be left. Reacted by Erlend E. Aasland erlend-aasland commented on Jan 3, 2025 Actually, to be on the safe side, please do the following, then build again:
$ git reset --hard HEAD
$ git clean -fdx picnixz commented on Jan 3, 2025 FTR: git clean -fdx would also remove all files that you manually added to the CPython project but are not in .gitignore and not committed (I have some) so I'd advise using a different directory than the directory you're usually using for development. ned-deily commented on Jan 14, 2025 I also see unreachable-code warnings in generated_cases.c.h but only when not using --with-pydebug.
FTR, using the current HEAD of main using Apple-supplied clang. Environment is current macOS and Xcode releases. Also same warnings with a slightly older release of Xcode and clang.
$ git show
commit 1153e66e20124b8f3484bcaddbc0e252d31161a6 (HEAD -> main, upstream/main, upstream/HEAD)
Author: Victor Stinner <[email protected]>
Date: Tue Jan 14 11:18:52 2025 +0100
gh-109959: Skip test_glob.test_selflink() flaky test (#128812)
[...]
$ clang --version
Apple clang version 16.0.0 (clang-1600.0.26.6)
Target: arm64-apple-darwin24.2.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
$ xcodebuild -version
Xcode 16.2
Build version 16C5032a
$ sw_vers
ProductName: macOS
ProductVersion: 15.2
BuildVersion: 24C101
$ CC=clang ./configure && make -j4
[...]
clang -c -fno-strict-overflow -Wsign-compare -Wunreachable-code -DNDEBUG -g -O3 -Wall -std=c11 -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -Wstrict-prototypes -Werror=implicit-function-declaration -fvisibility=hidden -Werror=unguarded-availability -I./Include/internal -I./Include/internal/mimalloc -I. -I./Include -DPy_BUILD_CORE -o Python/ceval.o Python/ceval.c
In file included from Python/ceval.c:906:
Python/generated_cases.c.h:4489:34: warning: code will never be executed [-Wunreachable-code]
for (int i = 0; i < total_args; i++) {
^
Python/generated_cases.c.h:965:34: warning: code will never be executed [-Wunreachable-code]
for (int i = 0; i < total_args; i++) {
^
Python/generated_cases.c.h:824:31: warning: code will never be executed [-Wunreachable-code]
for (int _i = oparg; --_i >= 0;) {
^~~~~
Python/generated_cases.c.h:710:31: warning: code will never be executed [-Wunreachable-code]
for (int _i = oparg*2; --_i >= 0;) {
^~~~~
picnixz commented on Jan 14, 2025 chris-eibl commented on Jan 14, 2025 Those are preceded by if (CONVERSION_FAILED(...)) which expands to if (0) in a "regular GIL" build, i.e. when Py_GIL_DISABLED is not defined. Interestingly, there are more such ifs, but not in all cases the warning is emitted for the following code line.
I think like unused labels are suppressed in generated code, these should be suppressed, too.
I've added # pragma GCC diagnostic ignored "-Wunreachable-code" to
|
#if defined(__GNUC__) |
|
# pragma GCC diagnostic push |
|
# pragma GCC diagnostic ignored "-Wunused-label" |
and also added || defined(__clang_) to get rid of this warning in clang-cl based builds ... picnixz commented on Jan 14, 2025 For clang, can't we add #pragma clang diagnostic? Also, I believe we should patch Tools/generator_cases.py instead of ceval.c as this is the script responsible for generating Python/generated_cases.c.h and only patch it locally and not make a global #pragma (but I don't know if it's feasible) chris-eibl commented on Jan 14, 2025 "Regular" clangs react on __GNUC__, I only added __clang__ because I did not want to see those warnings in Windows using clang-cl, which does (must) not define __GNU__.
I agree that patching Tools/generator_cases.py would be even better if someone wants to bite that bullet :) srinivasreddy commented on Jan 15, 2025 ContributorAuthor More actions I’m still able to reproduce the warnings with this workflow, which effectively eliminates the possibility that any custom settings or files are causing interference.
git clone https://github.com/python/cpython.git cpython_dev --depth=1
cd cpython_dev
./configure
make
erlend-aasland commented on May 12, 2025 At HEAD == 5dbd27d I get none of the "unreachable code" warnings mentioned in the OP. I do get one regarding the newly added zstd module, though (fixing that one via the zstd issue: #133947)1. Can we close this as out-of-date?
MetadataMetadatabuildThe build process and cross-buildThe build process and cross-buildinterpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)pendingThe issue will be closed if no feedback is providedThe issue will be closed if no feedback is providedtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error DevelopmentNo branches or pull requestsIssue actions
|