samyyc.dev
LOC::Macau, China

..UTC+8

samyyc.dev

-- BPM

Fri Dec 12 2025

A C++ Compile Error I Ran Into

#118

/

samyyc

/

297 words

/

Updated 357 days ago

/

[中文]

I was working on a program related to C#'s CoreCLR Profiling API. I needed to write something for a C# program that records the StackTrace when it crashes.

I hit a problem when building on Linux. The error looked like this:

error: /usr/include/c++/14/bits/ranges_base.h:858:27: error: no matching function for call to ‘move()’
  858 |           __it = std::move(__bound);
      |                  ~~~~~~~~~^~~~~~~~~
In file included from /usr/include/c++/14/bits/atomic_base.h:39,
                 from /usr/include/c++/14/atomic:50,
                 from src/CorProfiler.h:3:
/usr/include/c++/14/bits/move.h:126:5: note: candidate: ‘template<class _Tp> constexpr typename std::remove_reference<_Tp>::type&& std::move(_Tp&&)’
  126 |     move(_Tp&& __t) noexcept
      |     ^~~~
/usr/include/c++/14/bits/move.h:126:5: note:   candidate expects 1 argument, 0 provided
In file included from /usr/include/c++/14/bits/specfun.h:43,
                 from /usr/include/c++/14/cmath:3898,
                 from /usr/include/c++/14/math.h:36,
                 from vendor/runtime/src/coreclr/pal/inc/pal.h:44,
                 from vendor/runtime/src/coreclr/pal/inc/rt/palrt.h:121,
                 from vendor/runtime/src/coreclr/pal/inc/rt/rpc.h:15,
                 from vendor/runtime/src/coreclr/pal/inc/rt/objidl.h:12,
  > in src/CorProfiler.cpp

You can see std::move() says it got no arguments, but that line is std::move(__bound),

which means __bound got replaced by a macro.

I searched the CoreCLR project and found that specstrings.h and related headers define __bound. Those headers are under the pal directory.

pal stands for Platform Abstraction Layer; it's the part of CoreCLR used for platform compatibility.

I found that another header, specstrings_undef.h, undefines everything it defines.

So all we need to do is include this header at the end of the file that's throwing the error.