FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-120321: Avoid `-Wunreachable-code` warning on Clang by colesbury · Pull Request #143022 · python/cpython · GitHub

/ cpython Public

gh-120321: Avoid -Wunreachable-code warning on Clang - #143022

Merged
colesbury merged 1 commit into
python:mainfrom
colesbury:gh-120321-unused-code
Dec 20, 2025
Merged

gh-120321: Avoid -Wunreachable-code warning on Clang#143022
colesbury merged 1 commit into
python:mainfrom
colesbury:gh-120321-unused-code

Conversation

colesbury commented Dec 20, 2025
edited by bedevere-app Bot
Loading

Copy link
Copy Markdown
Contributor

Copy link
Copy Markdown
Contributor Author

I hate this, but I hate the other options even more.

mpage left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

We'll end up seeing the warning if clang's analysis gets more capable, right? I guess that's still better than disabling warnings around the block in the default build.

Test failure looks unrelated.

Copy link
Copy Markdown
Contributor Author

We'll end up seeing the warning if clang's analysis gets more capable, right?

I think it's more a matter of convention than capability. Clang can easily optimize through all these things and this warning is only enabled in optimized builds (not debug builds).

Clang doesn't warn for things like:

if (1) {
}
unreachable_code; // OK

But it warns for:

if ((expr, 1)) {
}
unreachable_code; // warning: code will never be executed [-Wunreachable-code]

But not for:

if ((expr, 1) || (1)) {
}
unreachable_code; // OK

But you can't put that expression in a macro:

#define MACRO (expr, 1) || (1)

if (MACRO) {
}
unreachable_code; // warning: code will never be executed [-Wunreachable-code]

colesbury merged commit 7607712 into python:main Dec 20, 2025
87 of 89 checks passed
colesbury deleted the gh-120321-unused-code branch December 20, 2025 19:42
cocolato pushed a commit to cocolato/cpython that referenced this pull request Dec 22, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants


Back | FazBrowse Home | New Git URL