-
Notifications
You must be signed in to change notification settings - Fork 15.4k
Closed as not planned
Closed as not planned
Copy link
Labels
clang:diagnosticsNew/improved warning or error message in Clang, but not in clang-tidy or static analyzerNew/improved warning or error message in Clang, but not in clang-tidy or static analyzerinvalidResolved as invalid, i.e. not a bugResolved as invalid, i.e. not a bug
Description
When compiling unreachable_warning.cpp (with the content below) using option -Wunreachable-code-break, a warning is triggered as expected:
void f(int i)
{
switch (i)
{
case 3: return; break;
}
}The warning emitted:
[user@host]$ clang++ -c -Wunreachable-code-break unreachable_warning.cpp
unreachable_warning.cpp:5:25: warning: 'break' will never be executed [-Wunreachable-code-break]
case 3: return; break;
^~~~~
1 warning generated.However if unreachable_warning.cpp is wrapped in another source file (as is frequently done in "unity builds" or "jumbo builds") then the warning is no longer emitted:
[user@host]$ cat unity_build.cpp
#include "unreachable_warning.cpp"
[user@host]$ clang++ -c -Wunreachable-code-break unity_build.cpp
[user@host]$
Metadata
Metadata
Assignees
Labels
clang:diagnosticsNew/improved warning or error message in Clang, but not in clang-tidy or static analyzerNew/improved warning or error message in Clang, but not in clang-tidy or static analyzerinvalidResolved as invalid, i.e. not a bugResolved as invalid, i.e. not a bug