Repository navigation
Unreachable code warnings while building latest main at 48c70b8 #128086
Description
Activity
- addedtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
on Dec 19, 2024 - changed the title
[-]Warnings while building latest main [/-][+]Unreachable code warnings while building latest main at 48c70b8[/+]on Dec 19, 2024 I have updated the tcl-tk to version 9.0.0_1, the warnings are gone. Please refer - build.log
- addedbuildThe build process and cross-buildThe build process and cross-buildinterpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)
on Dec 20, 2024 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?
- addedpendingThe issue will be closed if no feedback is providedThe issue will be closed if no feedback is provided
on Jan 3, 2025 Like gcc compiler version? and ...?
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)?➜ 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/binStill unable to reproduce. I'm on the same macOS version and the same compiler.
Here is the
./configureoutput i have captured.Here is the make output i have capture with the command -
make &> make.log. You should be able to see the warnings in themake.logfile.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
Try to also do a
make distclean,make cleanandmake cleantest. Some files might be left.Reacted by Erlend E. AaslandActually, to be on the safe side, please do the following, then build again:
$ git reset --hard HEAD $ git clean -fdx
FTR:
git clean -fdxwould also remove all files that you manually added to the CPython project but are not in.gitignoreand not committed (I have some) so I'd advise using a different directory than the directory you're usually using for development.I also see
unreachable-codewarnings ingenerated_cases.c.hbut only when not using--with-pydebug.FTR, using the current HEAD of
mainusing 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 <vstinner@python.org> 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;) { ^~~~~- removedpendingThe issue will be closed if no feedback is providedThe issue will be closed if no feedback is provided
on Jan 14, 2025 cc @markshannon
Those are preceded by
if (CONVERSION_FAILED(...))which expands toif (0)in a "regular GIL" build, i.e. whenPy_GIL_DISABLEDis not defined. Interestingly, there are more suchifs, 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
Lines 725 to 727 in f26daa9
#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 ...For clang, can't we add
#pragma clang diagnostic? Also, I believe we should patchTools/generator_cases.pyinstead ofceval.cas this is the script responsible for generatingPython/generated_cases.c.hand only patch it locally and not make a global#pragma(but I don't know if it's feasible)"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.pywould be even better if someone wants to bite that bullet :)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- addedpendingThe issue will be closed if no feedback is providedThe issue will be closed if no feedback is provided
on May 12, 2025
Bug report
Bug description:
I ran the
./configureandmake, here are the warnings shown.Operating System:
Main branch commit : 48c70b8
CPython versions tested on:
CPython main branch
Operating systems tested on:
macOS