[clang-tidy] detect unchecked stream extraction
Open
check-request
clang-tidy
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
```cpp
#include
void f()
{
std::istringstream iss("str");
double d;
iss >> d;
}
```
The stream extraction to `d` will fail and it needs to be checked by either:
- the operation itself via `if (iss >> d)`
- the failure state of the stream via `iss.fail()` or `if (iss)`
- exceptions raised by the stream - requires `iss.exceptions(std::ifstream::failbit)` to be called before the operation
Contributor guide
Assessment
This issue has not been assessed yet.