...
Thus, the following scenarios can result in undefined behavior:
- Receiving input from a stream directly following an output to that stream without an intervening call to
std::basic_filebuf<T>::seekoff()
if the file is not at end-of-file - Outputting to a stream after receiving input from that stream without a call to
std::basic_filebuf<T>::seekoff()
if the file is not at end-of-file
...
Alternately inputting and outputting from a stream without an intervening flush or positioning call is undefined behavior.
Rule | Severity | Likelihood | Remediation Cost | Priority | Level |
---|---|---|---|---|---|
FIO39FIO50-CPP | Low | Likely | Medium | P6 | L2 |
Automated Detection
...
CERT C Secure Coding Standard | FIO39-C. Do not alternately input and output from a stream without an intervening flush or positioning call |
Bibliography
[ISO/IEC 14882-2014] | Clause 27, "Input/Output Library" |
[ISO/IEC 9899:1999] | 7.19.5.3, "The fopen Function" |
...