Intel® C++ Compiler
Support and discussions for creating C++ code that runs on platforms based on Intel® processors.
Announcements
Welcome to the Intel Community. If you get an answer you like, please mark it as an Accepted Solution to help others. Thank you!
7569 Discussions

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

AndrewC
New Contributor I
781 Views

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

 

3 Replies
PrasanthD_intel
Moderator
770 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


AndrewC
New Contributor I
761 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);
    }
};

 

Viet_H_Intel
Moderator
265 Views

Hi Andrew,


Sorry, but our Developer doesn't plan to fix this issue. I am going to close it as "wont fix".


Thanks,

Viet


Reply