gh-120321: Avoid `-Wunreachable-code` warning on Clang by colesbury · Pull Request #143022 · python/cpython
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]