You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Disable unreachable-code diagnostic on speficic constants/comparison #241751
<source>:16:9: warning: code will never be executed [-Wunreachable-code]
16 | foo();
| ^~~
<source>:15:50: warning: code will never be executed [-Wunreachable-code]
15 | if(platform::current != platform::windows && condition){
| ^~~~~~~~~
Note that (currently) the warning is not triggered for a switch statement, but transforming an if to a switch is error-prone, and does in general not improve the legibility.
It is possible to suppress the warning locally with a pragma, but adding such pragmato every if-statement is repetitive and error-prone.
Is there a way to tell clang that the constant value platform::current depends on the compiler settings, and branches that depend on it are not necessarily dead?
<source>:16:9: warning: code will never be executed [-Wunreachable-code]
16 | foo();
| ^~~
<source>:15:50: warning: code will never be executed [-Wunreachable-code]
15 | if(platform::current != platform::windows && condition){
| ^~~~~~~~~
Note that (currently) the warning is not triggered for a switch statement, but transforming an if to a switch is error-prone, and does in general not improve the legibility.
It is possible to suppress the warning locally with a pragma, but adding such pragmato every if-statement is repetitive and error-prone.
Is there a way to tell clang that the constant value platform::current depends on the compiler settings, and branches that depend on it are not necessarily dead?
Activity
llvmorg-github-actions commentedon Nov 12, 2026
@llvm/issue-subscribers-clang-frontend
Author: Federico Kircheis (fekir)
Details
I have following patternbut with
-Wunreachable-code, clang diagnosesNote that (currently) the warning is not triggered for a
switchstatement, but transforming anifto aswitchis error-prone, and does in general not improve the legibility.It is possible to suppress the warning locally with a
pragma, but adding suchpragmato every if-statement is repetitive and error-prone.Is there a way to tell clang that the constant value
platform::currentdepends on the compiler settings, and branches that depend on it are not necessarily dead?live example: https://compiler-explorer.com/z/Y7455nzYW