Repository navigation
Unreachable code warnings while building latest main at 48c70b8 #128086
Copy link
Copy link
Closed
Labels
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
Description
Bug 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
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
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
Activity
[-]Warnings while building latest main [/-][+]Unreachable code warnings while building latest main at 48c70b8[/+]srinivasreddy commentedon Dec 19, 2024
I have updated the tcl-tk to version 9.0.0_1, the warnings are gone. Please refer - build.log
erlend-aasland commentedon 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 commentedon Jan 3, 2025
Like gcc compiler version? and ...?
erlend-aasland commentedon 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 commentedon Jan 3, 2025
erlend-aasland commentedon Jan 3, 2025
Still unable to reproduce. I'm on the same macOS version and the same compiler.
srinivasreddy commentedon Jan 3, 2025
Here is the
./configureoutput i have captured.config.log
srinivasreddy commentedon Jan 3, 2025
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.make.log
Main branch at b4f799b
picnixz commentedon Jan 3, 2025
Try to also do a
make distclean,make cleanandmake cleantest. Some files might be left.erlend-aasland commentedon Jan 3, 2025
Actually, to be on the safe side, please do the following, then build again:
picnixz commentedon Jan 3, 2025
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.ned-deily commentedon Jan 14, 2025
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.picnixz commentedon Jan 14, 2025
cc @markshannon
chris-eibl commentedon Jan 14, 2025
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"tocpython/Python/ceval.c
Lines 725 to 727 in f26daa9
and also added
|| defined(__clang_)to get rid of this warning in clang-cl based builds ...picnixz commentedon Jan 14, 2025
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)chris-eibl commentedon 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.pywould be even better if someone wants to bite that bullet :)srinivasreddy commentedon Jan 15, 2025
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.
erlend-aasland commentedon 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?Footnotes
fix merged ↩