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

    <tr>
        <th>Summary</th>
        <td>
            [Msan]False positive reported of std::__1::basic_istream<char, std::__1::char_traits<char>>& std::__1::getline
        </td>
    </tr>

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

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

    <tr>
      <th>Reporter</th>
      <td>
          zhaojiangkun-1
      </td>
    </tr>
</table>

<pre>
    When I use getline, there are some warnings even though it's initialized.
Is this a false positive behavior of getline?
```#include <iostream>
#include <string>
class A
{
public:
    A () {}
    ~A() {}
    void func1() noexcept;
};

void A::func1() noexcept
{
    std::string str = "heloworld";
    getline(std::cin, str, '\n');
    std::cout << str << std::endl;
}

int main() {
    A a {};
    a.func1();
    return 0;
}
```
Compiler version:
```
clang version 15.0.4
Target: aarch64-unknown-linux-gnu
Thread model: posix
```
```
[root@xxxxx]# ./msan-run
==3544==WARNING: MemorySanitizer: use-of-uninitialized-value
    #0 0xaaaab0ade4b4 in std::__1::basic_istream<char, std::__1::char_traits<char>>& std::__1::getline<char, std::__1::char_traits<char>, std::__1::allocator<char>>(std::__1::basic_istream<char, std::__1::char_traits<char>>&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>&, char) /xxxxx/usr/include/c++/v1/istream:1507:9
    #1 0xaaaab0ade024 in A::func1() /home/ci/workspace/tmp-warning/test.cpp:14:5
    #2 0xaaaab0ade164 in main /home/ci/workspace/tmp-warning/test.cpp:20:7
    #3 0xe7fbe5a2ae6c  (/usr/lib64/libc.so.6+0x2ae6c)
    #4 0xe7fbe5a2af48 in __libc_start_main (/usr/lib64/libc.so.6+0x2af48)
    #5 0xaaaab0a5b52c in _start /xxxx/aarch64-aos-linux/glibc/2.34-AOS4.0/glibc-2.34/csu/../sysdeps/aarch64/start.S:81

SUMMARY: MemorySanitizer: use-of-uninitialized-value /xxxx/usr/include/c++/v1/istream:1507:9 in std::__1::basic_istream<char, std::__1::char_traits<char>>& std::__1::getline<char, std::__1::char_traits<char>, std::__1::allocator<char>>(std::__1::basic_istream<char, std::__1::char_traits<char>>&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>&, char)
==3544==WARNING: MemorySanitizer: use-of-uninitialized-value
    #0 0xaaaab0adf534 in std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>::clear[abi:v15004]() /xxxxxxx/usr/include/c++/v1/string:3328:9
    #1 0xaaaab0ade4e8 in std::__1::basic_istream<char, std::__1::char_traits<char>>& std::__1::getline<char, std::__1::char_traits<char>, std::__1::allocator<char>>(std::__1::basic_istream<char, std::__1::char_traits<char>>&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>&, char) /xxxxxxx/usr/include/c++/v1/istream:1513:19
    #2 0xaaaab0ade024 in A::func1() /home/ci/workspace/tmp-warning/test.cpp:14:5
    #3 0xaaaab0ade164 in main /home/ci/workspace/tmp-warning/test.cpp:20:7
    #4 0xe7fbe5a2ae6c  (/usr/lib64/libc.so.6+0x2ae6c)
    #5 0xe7fbe5a2af48 in __libc_start_main (/usr/lib64/libc.so.6+0x2af48)
    #6 0xaaaab0a5b52c in _start /xxxxxx/aarch64-aos-linux/glibc/2.34-AOS4.0/glibc-2.34/csu/../sysdeps/aarch64/start.S:81

SUMMARY: MemorySanitizer: use-of-uninitialized-value /xxxxx/usr/include/c++/v1/string:3328:9 in std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>::clear[abi:v15004]()
hello
==3544==WARNING: MemorySanitizer: use-of-uninitialized-value
    #0 0xaaaab0ae106c in std::__1::basic_ostream<char, std::__1::char_traits<char>>& std::__1::__put_character_sequence<char, std::__1::char_traits<char>>(std::__1::basic_ostream<char, std::__1::char_traits<char>>&, char const*, unsigned long) /xxxxx/usr/include/c++/v1/ostream:760:13
    #1 0xaaaab0adeed0 in std::__1::basic_ostream<char, std::__1::char_traits<char>>& std::__1::operator<<<char, std::__1::char_traits<char>, std::__1::allocator<char>>(std::__1::basic_ostream<char, std::__1::char_traits<char>>&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&) /xxxxx/usr/include/c++/v1/ostream:1086:12
    #2 0xaaaab0ade060 in A::func1() /home/ci/workspace/tmp-warning/test.cpp:15:15
    #3 0xaaaab0ade164 in main /home/ci/workspace/tmp-warning/test.cpp:20:7
    #4 0xe7fbe5a2ae6c  (/usr/lib64/libc.so.6+0x2ae6c)
    #5 0xe7fbe5a2af48 in __libc_start_main (/usr/lib64/libc.so.6+0x2af48)
    #6 0xaaaab0a5b52c in _start /xxxxxx/aarch64-aos-linux/glibc/2.34-AOS4.0/glibc-2.34/csu/../sysdeps/aarch64/start.S:81

SUMMARY: MemorySanitizer: use-of-uninitialized-value /xxxxxx/usr/include/c++/v1/ostream:760:13 in std::__1::basic_ostream<char, std::__1::char_traits<char>>& std::__1::__put_character_sequence<char, std::__1::char_traits<char>>(std::__1::basic_ostream<char, std::__1::char_traits<char>>&, char const*, unsigned long)
hello
MemorySanitizer: 3 warnings reported.

```

</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJzsWU1v2zgT_jX0hbBAkaItH3yQ4-pFD-kLNLso9mRQ0thiS5NaknLSHva3L6gP2wnSdJNNWmSRQAjl4fAZfsw8DyQJ5-ROAywRXyG-nojW18Yuv9XCfJZC7760ehpPClN9XX6qQeP3uHWAd-CV1IDoBfY1WMDCAnZmD_haWC31zmE4gMa-Nu2uxtIjOndYaumlUPIbVBEi2XuHfS0dFngrlAPcGCe9PAAuoBYHaSw222MkliOSoRkZLsqkLlVbAUbsQhrnLYg9Yu-C060-563Uu76nVMI5nAWf-QqRrGkLJUvEggVjjDOMaIroAofu-Xqw_pXdZz0YWeFtq8t46NUGbkpoPGKrLsB6uCFZ55qFMCy7d8Q4n4DrfNV79hPHzluM2BojSmtQ5tpYVSF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