Open
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.