[libcxx-commits] [libcxx] [libc++] Fix missing 'get_new_handler()' for Windows builds (PR #150182)

A. Jiang via libcxx-commits libcxx-commits at lists.llvm.org
Wed Jul 30 02:25:12 PDT 2025


================
@@ -11,9 +11,7 @@
 #include "include/atomic_support.h"
 
 #if defined(_LIBCPP_ABI_MICROSOFT)
-#  if !defined(_LIBCPP_ABI_VCRUNTIME)
-#    define _LIBPCPP_DEFINE_NEW_HANDLER
-#  endif
+#  define _LIBPCPP_DEFINE_NEW_HANDLER
----------------
frederick-vs-ja wrote:

> > I wonder whether we should include `<vcruntime_new.h>` instead of `<new.h>` (in other headers).
> 
> Unfortunately that would increase the scope of this PR, which is why it exists in standalone form rather than with #14899

I currently think that this is a simpler way to resolving declaration mismatch. If we don't do so, perhaps we need to define `_CRTIMP2` properly in some configuration header.

> > This doesn't seem right. The definitions provided `__new_handler` are dummy and non-conformant. Perhaps we should rely on VCRuntime's functionalities.
> 
> Care to elaborate? from what I've seen in MS-STL they both have similar implementations.

The definitions provided in `libcxx/src/new_handler.cpp` don't interact with `operator new`/`operator new[]` (and thus non-conforming), and merely let the library compile under some conditions.

The proper implementations are expected to be provided by the underlying library (libsupc++, libc++abi, or VCRuntime, possibly along with some parts of MSVC STL).

https://github.com/llvm/llvm-project/pull/150182


More information about the libcxx-commits mailing list