llvm / llvm/llvm-project

False positive `-Winvalid-noreturn` if `throw` is followed by `try`/`catch`

Open
#174,822 1 comment 0 reactions 0 assignees View on GitHub
clang:diagnostics confirmed false-positive
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

Compile with `-fsyntax-only -Winvalid-noreturn`:

```c++
[[noreturn]] void test() {
throw 1;
try {} catch(...) {}
}
```

This produces:
```
:4:1: warning: function declared 'noreturn' should not return [-Winvalid-noreturn]
4 | }
| ^
```

I think that's because we don't add exception handling edges for calls to the CFG, so we mark all catch blocks as reachable. But this is just speculation.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.