-
Couldn't load subscription status.
- Fork 15k
Open
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 analyzerconfirmedVerified by a second partyVerified by a second partyfalse-positiveWarning fires when it should notWarning fires when it should notquality-of-implementation
Description
I have the following snippet:
int foo(int) {
bool matched = false;
do {
if (matched) {
break;
}
return 42;
} while(false);
}
int main() {
foo(42);
}
I compile it with clang++-18:
$ clang++-18 --version
Ubuntu clang version 18.1.8 (++20240731024944+3b5b5c1ec4a3-1~exp1~20240731145000.144)
Target: x86_64-pc-linux-gnu
Thread model: posix
$ clang++-18 -Wreturn-type main.cpp
main.cpp:9:1: warning: non-void function does not return a value in all control paths [-Wreturn-type]
9 | }
| ^
1 warning generated.
Variable matched is effectively constant and there are no paths that "do not return a value".
The expected behavior is such that there should be no such warning.
Danil42RussiaDanil42RussiaDanil42RussiaDanil42Russia
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 analyzerconfirmedVerified by a second partyVerified by a second partyfalse-positiveWarning fires when it should notWarning fires when it should notquality-of-implementation