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

    <tr>
        <th>Summary</th>
        <td>
            MemorySanitizer `use-of-uninitialized-value` with `std::istringstream::rdstate()`
        </td>
    </tr>

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

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

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

<pre>
    ```cpp
#include <sstream>

int main()
{
    std::istringstream istr;
    if (istr.rdstate()) {
    }
}
```

```
==1==WARNING: MemorySanitizer: use-of-uninitialized-value
    #0 0x562dd2ef37d9  (/app/output.s+0xae7d9)
    #1 0x7f3190ffd0b2  (/lib/x86_64-linux-gnu/libc.so.6+0x240b2) (BuildId: 9fdb74e7b217d06c93172a8243f8547f947ee6d1)
    #2 0x562dd2e6935d  (/app/output.s+0x2435d)

SUMMARY: MemorySanitizer: use-of-uninitialized-value (/app/output.s+0xae7d9) 
```

https://godbolt.org/z/3dazzno1f

This has been reduced from the original code that has a function which takes an `std::istream` and calls `std::istream::good()`.

I checked the documentation and there's no indication that I cannot immediately call this function. My code actually matches the example on https://en.cppreference.com/w/cpp/io/basic_ios/rdstate.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyVVE1zmzAQ_TVw0ZgRAoQ5cEiappNDeujHdHrqCGkxaoXkQVJs59d3wXbipJ10ygghdrW7b5921Tl1aBNOj0Nutwm9SehVwgptpYkKSFK88z5MIMakeH_SLrO2gYxC24StE9acNPX1cUHw8UElxRUOjfbabo5eyPyXFBf7dE_QxyzOJuWDCHByyRrywmFS35zDnBdn5JfAXguLGxz58fPt6tPHu48fEBS5h9FNh8_C6qAfYZpF0cPK9ato9SwUBuVq9SBMhAsQrKCE7ivOlGLQF7VqZiECvhVIH7t1MWxjyHzCruleAOqf6DnZ52hf90Xe0L5XtGNne6M7nPdr_oOXK6Nt3K82Nh4VMvMu44tPVqLNQg5bX0dt1N3MM2l61dUl1B3La0W5bIq8ZmLNyqJfV2XdN2UNwFX-Gg17zoY3RaXeyAZ9Ver5sJf589f7-6tP3_-b0X9zRt444yGErZ-ri93i2DjVORMyN23w7xHfQonHR-vy_tLoy6A9GYQnHYAlE6goQZF-ciMJAxA36Y22whDpsO7DIMKyWZA-Whm0s2Q3aDmQIH4Bii1BTC9qfO4RTlGjiBTG-L9uWH42zqlTkXOaXWK8I3IA-QtxzZCUk3EEiz0xh58do3TC_qg9sY5oq7Q86ha4aCysdYHocQSlsZPMYYGCakz9nEdG7g_HJIUMEdUHbOSAcf0SFPZi3Brkw5KXNIPN8IaYoEcIVkIm3YjSHb5yOUXtcOqE1_KHdniWt6d2zlJoc85zVpdlnqeqLVRTNCINOhhoX1XNTNobfYj87nQY_qD26X45il5eJJymcTLtq6JBN7E7JWHMw_mz2k7uJ8gwJ-R9hDmRqi7yMh1aygWtegWKNYp3MqeqKKsOVCVFUzVNnRrRgfFtUl0njFnYkcUFrpPqJtUto4zRNd4ANeVVnuXlmtVVLzin67yRVVJSwCvVZDOOuZrTqV0gdXHjUWkwU_-sFN7rjQVYwqF_EcPgprbXE-zEA6RL7HbB_hsTHse2">