<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - MemorySanitizer: use-of-uninitialized-value in std::string s = "x"; std::strlen(s.c_str());"
   href="https://bugs.llvm.org/show_bug.cgi?id=50114">50114</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>MemorySanitizer: use-of-uninitialized-value in std::string s = "x"; std::strlen(s.c_str());
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>libc++
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>10.0
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Windows NT
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>All Bugs
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>nok.raven@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org, mclow.lists@gmail.com
          </td>
        </tr></table>
      <p>
        <div>
        <pre>#include <string>

int main()
{
    std::string s = "x";
    (void)std::strlen(s.c_str());
}

clang++-11 -fsanitize=memory -stdlib=libc++ -g z.cpp -o z && ./z

==63085==WARNING: MemorySanitizer: use-of-uninitialized-value
    #0 0x49a3ab in std::__1::basic_string<char, std::__1::char_traits<char>,
std::__1::allocator<char> >::__get_pointer() const
/usr/lib/llvm-11/bin/../include/c++/v1/string:1517:17
    #1 0x49a2b8 in std::__1::basic_string<char, std::__1::char_traits<char>,
std::__1::allocator<char> >::data() const
/usr/lib/llvm-11/bin/../include/c++/v1/string:1245:75
    #2 0x499f10 in std::__1::basic_string<char, std::__1::char_traits<char>,
std::__1::allocator<char> >::c_str() const
/usr/lib/llvm-11/bin/../include/c++/v1/string:1243:55
    #3 0x499d34 in main /home/user/z.cpp:6:25
    #4 0x7f8a3bdb6cb1 in __libc_start_main csu/../csu/libc-start.c:314:16
    #5 0x41d26d in _start (/home/user/z+0x41d26d)

SUMMARY: MemorySanitizer: use-of-uninitialized-value
/usr/lib/llvm-11/bin/../include/c++/v1/string:1517:17 in
std::__1::basic_string<char, std::__1::char_traits<char>,
std::__1::allocator<char> >::__get_pointer() const
Exiting

Clang/libc++ 10+ are affected

<a href="https://godbolt.org/z/h8Y5K1M9K">https://godbolt.org/z/h8Y5K1M9K</a></pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>