Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

code will never be executed warning in dictobject.c #118849

Closed
sobolevn opened this issue May 9, 2024 · 0 comments
Closed

code will never be executed warning in dictobject.c #118849

sobolevn opened this issue May 9, 2024 · 0 comments
Assignees
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs) topic-free-threading type-bug An unexpected behavior, bug, or error

Comments

@sobolevn
Copy link
Member

sobolevn commented May 9, 2024

Bug report

Here's how this code looks right now:

cpython/Objects/dictobject.c

Lines 5489 to 5500 in c3643a1

fail:
di->di_dict = NULL;
Py_DECREF(d);
return -1;
int res;
try_locked:
Py_BEGIN_CRITICAL_SECTION(d);
res = dictiter_iternextitem_lock_held(d, self, out_key, out_value);
Py_END_CRITICAL_SECTION();
return res;
}

gcc -c -fno-strict-overflow -Wsign-compare -Wunreachable-code -DNDEBUG -g -O3 -Wall -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include  -D_Py_TIER2=1 -D_Py_JIT -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 -I/opt/homebrew/opt/openssl/include -I/opt/homebrew/opt/openssl/include  -DPy_BUILD_CORE -o Objects/dictobject.o Objects/dictobject.c
Objects/dictobject.c:5494:5: warning: code will never be executed [-Wunreachable-code]
    int res;
    ^~~~~~~~
1 warning generated.

I have a PR ready.

Linked PRs

@sobolevn sobolevn added type-bug An unexpected behavior, bug, or error interpreter-core (Objects, Python, Grammar, and Parser dirs) topic-free-threading labels May 9, 2024
@sobolevn sobolevn self-assigned this May 9, 2024
sobolevn added a commit to sobolevn/cpython that referenced this issue May 9, 2024
miss-islington pushed a commit to miss-islington/cpython that referenced this issue May 9, 2024
…ject.c` (pythonGH-118850)

(cherry picked from commit 82abe75)

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
sobolevn added a commit that referenced this issue May 9, 2024
…bject.c` (GH-118850) (#118859)

gh-118849: Fix "code will never be executed" warning in `dictobject.c` (GH-118850)
(cherry picked from commit 82abe75)

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
@sobolevn sobolevn closed this as completed May 9, 2024
SonicField pushed a commit to SonicField/cpython that referenced this issue May 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs) topic-free-threading type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

1 participant