llvm / llvm/llvm-project

[clang-tidy] detect unchecked stream extraction

Open
#190,127 1 comment 0 reactions 0 assignees View on GitHub
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

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.