Issue 95875
Summary Difference in output when reading from tty between llvm-18 and gcc-12
Labels new issue
Assignees
Reporter m-chaturvedi
    ```
$  cat tty_reading.cpp
#include <fstream>
#include <iostream>

using namespace std;
void tty_read() {
  ifstream in("/dev/tty");
 cin.rdbuf(in.rdbuf());

  string str;
  getline(cin, str, '\n');
  cout << str << endl;
}

int main(int argc, char *argv[]) { tty_read(); }
```
```
$  cat build.sh
g++ tty_reading.cpp -o ./gcc_build
clang++-18 -stdlib=libc++ tty_reading.cpp -lc++abi -o ./clang_build
```
```
$ ./gcc_build
Hello
Hello
$ ./clang_build
Hello
There
How
are
```
Unlike `gcc_build`, `clang_build`  doesn't terminate taking input.
I have tried with the fstream in #76629 as well to no avail.

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

Reply via email to