<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/95875>95875</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            Difference in output when reading from tty between llvm-18 and gcc-12
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          m-chaturvedi
      </td>
    </tr>
</table>

<pre>
    ```
$  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.

</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyEVEHP4jgM_TXuxQIVF0p76OHjY9Huffc8ShO3zU6aosQt-v79qqUMiJnRSoiaPPs9O35UxWhbz1zB4QSHc6JG6YZQ9RvdKRnDxMYm9WC-KsjT9ZOeIf0A2iNqJSjy9S2wMta3W329PtDMeu1GwwjZZxMlsOoh--NXqB3e4eV7jNa36FXP8ao0YxQD2emOTYM1P4SBCqAS4biCiHYVROsXkIAuhiegi8jX8rP8QYXa-m0w9dgAFS_hnPOS9qCOEua2ooQnA7YsznoGKvSs-LnA9IlARzh8-vnxqoh6GGWeHLIl9RGyN-4peDy_Klsv2KtlnjlUodWzgu5UQKAPFdrpvsD1Kt5uB7ITPhnfNvmbxdajdWYbu_txC3QCOr2vGzcDboEurdbfloJ7tnbKrxWbXYGbKMbZGrKzs7X-HZNbEVXbB-3C80r8_73_ops_2bnhp_CR_JPGS87fHQdeT4fbPVCPkzfxf7yz3xkhT5_yebr4IE9fRfIU0QwcZ2MICofeeiWMor7P3rL-Osr2zvkXdmpilGDZ4M1Kh9IxPu2NQNkxz6lEFfHGzqEM6AdUk7Ju5UhMlZkyK1XC1e64K_JjsSsp6aqGS0M65Vo1uakb4v3eZGmjyzo_5DvaJ7ailPZpvitSyvKMtk2a58VB5aqpjzpjgn3K_azk3NRvh9AmNsaRq_JQHA-JUzW7uLxYiDzfcAHn_9_hnIRqrtnUYxthnzobJT5ZxIrj6mybhgN7zfOkwyjXUfDWscfVNtiEoZ99hDXLjdnjwrkrUHmDrdabHSVjcFUnco2QfQBdZndY6cZ6q4ce6DJXrI_NNQz_shagy9JpBLrcJ5kq-i8AAP__vy-DWQ">