<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 - string::size() use of uninitialized memory (MSan)"
   href="https://bugs.llvm.org/show_bug.cgi?id=32387">32387</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>string::size() use of uninitialized memory (MSan)
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>unspecified
          </td>
        </tr>

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

        <tr>
          <th>OS</th>
          <td>All
          </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>gonzalobg88@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org, mclow.lists@gmail.com
          </td>
        </tr></table>
      <p>
        <div>
        <pre>The following MWE produces a MemorySanitizer error:

MWE:

#include <vector>
#include <string>

int main() 
{
    auto vec = std::vector<std::string>{{"a"}, {"b"}, {"c"}};
    auto it = std::find(std::begin(vec), std::end(vec), "b");
    assert(it2 == vec.begin() + 1);
}

Error:

==25671==WARNING: MemorySanitizer: use-of-uninitialized-value
    #0 0x49a8ca in std::__1::basic_string<char, std::__1::char_traits<char>,
std::__1::allocator<char> >::size() const
/home/gonzalo/pool/msan/include/c++/v1/string:894:17
    #1 0x49a8ca in bool std::__1::operator==<char, std::__1::char_traits<char>,
std::__1::allocator<char> >(std::__1::basic_string<char,
std::__1::char_traits<char>, std::__1::allocator<char> > const&, char const*)
/home/gonzalo/pool/msan/include/c++/v1/string:3581
    #2 0x49a8ca in std::__1::__wrap_iter<std::__1::basic_string<char,
std::__1::char_traits<char>, std::__1::allocator<char> >*>
std::__1::find<std::__1::__wrap_iter<std::__1::basic_string<char,
std::__1::char_traits<char>, std::__1::allocator<char> >*>, char
[2]>(std::__1::__wrap_iter<std::__1::basic_string<char,
std::__1::char_traits<char>, std::__1::allocator<char> >*>,
std::__1::__wrap_iter<std::__1::basic_string<char, std::__1::char_traits<char>,
std::__1::allocator<char> >*>, char const (&) [2])
/home/gonzalo/pool/msan/include/c++/v1/algorithm:891
    #3 0x49a8ca in main test.cpp:7
    #4 0x7f220bb66b04 in __libc_start_main (/lib64/libc.so.6+0x21b04)
    #5 0x42384e in _start
/home/abuild/rpmbuild/BUILD/glibc-2.19/csu/../sysdeps/x86_64/start.S:122

SUMMARY: MemorySanitizer: use-of-uninitialized-value
/home/gonzalo/pool/msan/include/c++/v1/string:894:17 in
std::__1::basic_string<char, std::__1::char_traits<char>,
std::__1::allocator<char> >::size() const
Exiting</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>