<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 - __builtin_wmemchr does not work with clang-cl"
   href="https://bugs.llvm.org/show_bug.cgi?id=41226">41226</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>__builtin_wmemchr does not work with clang-cl
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>8.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>release blocker
          </td>
        </tr>

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

        <tr>
          <th>Component</th>
          <td>C++'17
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>powerchord@web.de
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>blitzrakete@gmail.com, erik.pilkington@gmail.com, llvm-bugs@lists.llvm.org, richard-llvm@metafoo.co.uk
          </td>
        </tr></table>
      <p>
        <div>
        <pre>int main()
{

static_assert(__has_feature(cxx_constexpr_string_builtins));  // is true
static_assert(__has_builtin(__builtin_wmemchr));  // is true

static_assert(!__builtin_wmemchr(nullptr, 0, 0));  // is true
__builtin_wmemchr(nullptr, 0, 0);  // no error reported

}

This program does not compile.

link.exe reports this error:
LNK2019 unresolved external symbol _wmemchr referenced in function _main

lld-link.exe reports this error:
undefined symbol: _wmemchr

This issue is related to <a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - clang-cl emits bogus error LNK2019: unresolved external symbol _wmemchr"
   href="show_bug.cgi?id=37911">Bug 37911</a>
(<a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - clang-cl emits bogus error LNK2019: unresolved external symbol _wmemchr"
   href="show_bug.cgi?id=37911#c1">https://bugs.llvm.org/show_bug.cgi?id=37911#c1</a>) reported by Stephan Lavavej
from Microsoft.

It seems that if __builtin_wmemchr is not forced to be evaluated at compile
time it is not "called" and clang emits the symbol _wmemchr instead. But
Microsoft's libraries do not have that symbol.

I think this is a bug. clang should be able to "call" its builtin function at
both compile time and run-time.

Maybe this is a leftover from previous clang versions, that is, before wmemchr
was made constexpr and builtin?

I tested this in VS 2017 and 2019 RC with the LLVM Compiler Toolchain
extension.</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>