| Issue |
175440
|
| Summary |
False positive `-Wunneeded-internal-declaration` for function only called in discarded statement
|
| Labels |
new issue
|
| Assignees |
|
| Reporter |
eisenwave
|
https://godbolt.org/z/5j7EYsYTh
```cpp
static void f() {}
int main() {
if constexpr (false) { f(); }
}
```
```
<source>:1:13: warning: function 'f' is not needed and will not be emitted [-Wunneeded-internal-declaration]
1 | static void f() {}
| ^
1 warning generated.
```
This feels like a false positive because normally, uses in discarded statements are still counted for the purpose of diagnostics. For example, I recall that older versions of Clang warned `-Wunused-parameter` historically, but no longer do for the following code:
```cpp
int g(int x) {
if constexpr (false) {
return x;
} else {
return 0;
}
}
```
The code is artificial; I ran into this issue in practice with:
```cpp
if constexpr (is_debug_build)
```
(because preprocessing is lame, and I didn't want `#if`)
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs