Issue 144952
Summary False positive Wreturn-type warning when a function either returns or throws
Labels new issue
Assignees
Reporter TiborGY
    Clang does not appear to be able to deduce that a function that always throws is effectively [[noreturn]], not even in seemingly trivial cases. Consider this:
```
void throwError(const std::string& msg){
    throw std::runtime_error(msg);
}

int ensureZero(const int i){
    if (i == 0) return 0;
 throwError("ERROR");
}

```
Compiling with `-Wall -Wextra -O3 -std=c++2c` yields a false positive warning:
`warning: non-void function does not return a value in all control paths [-Wreturn-type]`

_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to