<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 - clang++ miscompiles against MSVC standard library with -O2"
   href="https://bugs.llvm.org/show_bug.cgi?id=43710">43710</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>clang++ miscompiles against MSVC standard library with -O2
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>new-bugs
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>9.0
          </td>
        </tr>

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

        <tr>
          <th>OS</th>
          <td>other
          </td>
        </tr>

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

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

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

        <tr>
          <th>Component</th>
          <td>new bugs
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>karen@codesynthesis.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>htmldeveloper@gmail.com, llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=22688" name="attach_22688" title="Test program">attachment 22688</a> <a href="attachment.cgi?id=22688&action=edit" title="Test program">[details]</a></span>
Test program

Hello,

My system is Windows 10 with clang 9.0.0 (installed with
<a href="https://releases.llvm.org/9.0.0/LLVM-9.0.0-win64.exe">https://releases.llvm.org/9.0.0/LLVM-9.0.0-win64.exe</a>) and Microsoft Visual
Studio Community 2019, Version 16.3.1.

Under some circumstances a non-empty string passed into a function is seen by
the function code as an empty string.

The attached program reproduces the issue. It is expected to print 'abc' but
prints '' if compiled with -O2 or -O3:

<span class="quote">> clang++ -std=c++2a test.cxx
> a.exe</span >
'abc'
<span class="quote">>clang++ -std=c++2a -O2 test.cxx
>a.exe</span >
''

Note that the issue also reproduces if compile with clang-cl:

<span class="quote">> clang-cl /std:c++17 /EHsc test.cxx
> test.exe</span >
'abc'
<span class="quote">> clang-cl /std:c++17 /EHsc /O2 test.cxx
> test.exe</span >
''

Also note that the attached program is not exactly trivial but I was unable to
reduce it further.</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>