[llvm-bugs] [Bug 41226] New: __builtin_wmemchr does not work with clang-cl

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Mar 25 13:30:44 PDT 2019


https://bugs.llvm.org/show_bug.cgi?id=41226

            Bug ID: 41226
           Summary: __builtin_wmemchr does not work with clang-cl
           Product: clang
           Version: 8.0
          Hardware: PC
                OS: other
            Status: NEW
          Severity: release blocker
          Priority: P
         Component: C++'17
          Assignee: unassignedclangbugs at nondot.org
          Reporter: powerchord at web.de
                CC: blitzrakete at gmail.com, erik.pilkington at gmail.com,
                    llvm-bugs at lists.llvm.org, richard-llvm at metafoo.co.uk

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 Bug 37911
(https://bugs.llvm.org/show_bug.cgi?id=37911#c1) 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.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20190325/62e60dc9/attachment.html>


More information about the llvm-bugs mailing list