Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
New Contributor I
221 Views

Compiler 19.1 Update 2, Visual Studio 2019, wmemcmp undefined symbol

The following code fails to link

This bug has been reported multiple times in Compiler 19.0-19.1 . It makes std::filesystem unusable, among others.

Visual Studio 2019, C++17, x64/Release configuration or x64/Debug

1>filsystemcheck.obj : : error LNK2019: unresolved external symbol wmemcmp referenced in function "public: static int __cdecl std::_WChar_traits<wchar_t>::compare(wchar_t const * const,wchar_t const * const,unsigned __int64)" (?compare@?$_WChar_traits@_W@std@@SAHQEB_W0_K@Z)

 

#include <string>

int main()
{
	std::wstring a = L"Hallo";
	std::wstring b = L"Dulla";
	bool bRes = (a == b);
	return 0;
}

 

Clearly the problem ( since this happens when using C++17) is in the Visual C++ headers

#if _HAS_CXX17
        if constexpr (is_same_v<_Elem, wchar_t>) {
            return __builtin_wmemcmp(_First1, _First2, _Count);
        } else {
            return _Char_traits<_Elem, unsigned short>::compare(_First1, _First2, _Count);
        }
#else // _HAS_CXX17
        return _CSTD wmemcmp(
            reinterpret_cast<const wchar_t*>(_First1), reinterpret_cast<const wchar_t*>(_First2), _Count);
#endif // _HAS_CXX17

 

2 Replies
Highlighted
Moderator
210 Views

Hi Andrew,


Thanks for reporting the error.

We were able to reproduce the error with C++17 and ICPC 19.1.

We are escalating this issue to the concerned team.


Regards

Prasanth


0 Kudos
Highlighted
New Contributor I
201 Views

Hi,

There is a workaround/hack. Add a new C++ source file to the project that contains the following. The link will be satisfied.

extern "C" {
    int memcmp(
        void const* _Buf1,
        void const* _Buf2,
        size_t      _Size
    );

    int wmemcmp(
        const wchar_t* buffer1,
        const wchar_t* buffer2,
        size_t count
    )
    {
        return memcmp(buffer1, buffer2, count * 2);
    }
};

 

0 Kudos