Skip to content

<atomic>: clang-cl reports undeclared identifier '_InterlockedCompareExchange128_nf' for ARM64 #1491

@zufuliu

Description

@zufuliu

Describe the bug
clang-cl (LLVM-11.0.0-win64.exe from https://github.com/llvm/llvm-project/releases/tag/llvmorg-11.0.0) reports undeclared identifier _InterlockedCompareExchange128_nf at atomic(484,12) for ARM64 with -std:c++latest, no errors with -std:c++17 or -std:c++14 or without C++ language standard option.

STL/stl/inc/atomic

Lines 483 to 485 in 19c683d

#else // ^^^ _M_X64 / ARM64 vvv
return _InterlockedCompareExchange128_nf(_Dest, _Tmp[1], _Tmp[0], _Tmp) != 0;
#endif // ^^^ ARM64 ^^^

Command-line test case

C:\Temp>type repro.cpp
#include <atomic>

C:\Temp>clang-cl -c --target=aarch64-pc-windows-msvc .\repro.cpp

C:\Temp>clang-cl -c --target=aarch64-pc-windows-msvc -std:c++14 .\repro.cpp

C:\Temp>clang-cl -c --target=aarch64-pc-windows-msvc -std:c++17 .\repro.cpp

C:\Temp>clang-cl -c --target=aarch64-pc-windows-msvc -std:c++latest .\repro.cpp
In file included from .\repro.cpp:1:
D:\Program Files\Microsoft Visual Studio\2019\VC\Tools\MSVC\14.28.29333\include\atomic(484,12): error: use of undeclared identifier '_InterlockedCompareExchange128_nf'
    return _InterlockedCompareExchange128_nf(_Dest, _Tmp[1], _Tmp[0], _Tmp) != 0;
           ^
1 error generated.

Expected behavior
No errors like other architectures.

STL version
Visual Studio 2019 14.28.29333

Additional context
My failed GitHub Actions job Build with LLVM (Visual C++) for LLVMRelease configuration at
https://github.com/zufuliu/notepad2/runs/1424448830?check_suite_focus=true#step:7:7
It use LLVM_v142 toolchain from https://github.com/zufuliu/llvm-utils, also reproducible with LLVM (clang-cl) toolchain.

   In file included from ..\..\scintilla\src\AutoComplete.cxx:19:
  In file included from C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.28.29333\include\memory:18:
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.28.29333\include\atomic(484,12): error : use of undeclared identifier '_InterlockedCompareExchange128_nf' [D:\a\notepad2\notepad2\build\VS2017\Notepad2.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.28.29333\include\atomic(484,12): error :     return _InterlockedCompareExchange128_nf(_Dest, _Tmp[1], _Tmp[0], _Tmp) != 0; [D:\a\notepad2\notepad2\build\VS2017\Notepad2.vcxproj]

Metadata

Metadata

Assignees

No one assigned

    Labels

    ARM64Related to the ARM64 architecturebugSomething isn't workingfixedSomething works now, yay!

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions