Issue 184396
Summary Code in constexpr if branch is incorrectly considered unused
Labels new issue
Assignees
Reporter arnaudgolfouse
    Hello,
the following code incorrectly produce a warning (with `-Wunneeded-internal-declaration`):
```cpp
constexpr bool B = false;

static auto foo(int x) -> int { // warning: Function 'foo' is not needed and will not be emitted
    return x + 1;
}

int bar() {
    if constexpr (B) {
        return foo(1);
    } else {
        return 2;
 }
}
```
Although `foo` is (statically) never called, removing it would cause the `true` branch to fail to compile.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to