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

    <tr>
        <th>Summary</th>
        <td>
            std::ifstream eof difference between libc++ and libstdc++11
        </td>
    </tr>

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

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

    <tr>
      <th>Reporter</th>
      <td>
          morozyto
      </td>
    </tr>
</table>

<pre>
    Hi!

I have got this code:
`
#include <fstream>
#include <vector>

int main() {
 const std::string path = "/tmp/some_random_path"; // this file do not exist before running of program
    std::ofstream file_output(path);
 std::ifstream file_input(path, std::ios::in | std::ios::binary);
 file_input.peek();

    if (!file_input.eof()) {
        return 1;
    }
    std::vector<char> data = {'a', 'b', 'c'};
 file_output.write(data.data(), static_cast<long>(data.size()));
 file_output.flush();

    file_input.clear();
 file_input.peek();
    if (file_input.eof()) {
        return 2; // libc++
    }
    return 0; // libstdc++11
}
`

I tried to compile it with againt libstdc++11 ( clang++ main.cpp ) and against libc++ (clang++ -stdlib=libc++ main.cpp). I expect success return code for both libc++ and libstdc++11, but libc++ eof flag is not updated. Is it valid?

My specs:
Ubuntu Description: Ubuntu 20.04.4 LTS Release: 20.04 Codename: focal
Ubuntu clang version 15.0.7
Target: x86_64-pc-linux-gnu 
Thread model: posix
InstalledDir: /usr/bin 
Selected GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/10 
Selected multilib: .;@m64
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyUVU1v4zYQ_TX0ZRBBoizLPviQ2FW7QHvpbs8BRY4kthQpkCMn2V9fUJJjOZti0SCgCc578_GGQ4kQdGsRj6x4YsV5I0bqnD_2zrvvb-Q2tVNvx9804xlLzyx9nNcv0IkLQusIqNMBpFPI8sXIdumy4bm20owKgeWnJpBH0bP8l8-sF5Tk_M04rdoS9EJbxveMH4CVT_M5SGcDQSAVg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