Created
December 8, 2021 20:15
-
-
Save martyngigg/2f47c7b5ca398d83aa907feb9a179714 to your computer and use it in GitHub Desktop.
EOF bug in libc++
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <sstream> | |
int main() { | |
std::stringstream s; | |
s.exceptions(std::istream::eofbit); | |
s << "a"; | |
std::cout << "EOF? " << (s.eof() ? "T" : "F") << std::endl; | |
std::cout << "get: " << s.get() << std::endl; | |
std::cout << "EOF? " << (s.eof() ? "T" : "F") << std::endl; | |
std::cout << "get: " << s.get() << std::endl; // throws eoftbit=T | |
std::cout << "This line should not be reached!\n"; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment