[patch] [libcxx] new/new.cpp

G M gmisocpp at gmail.com
Mon Jan 6 04:45:11 PST 2014

Hi Everyone

MSVC issues a lot of warnings because it doesn't handle exception
specifications well. I think MSVC treats a throw(std::bad_alloc) exception
on the operator new function as if it were throw(...), but it issues a
noisy warning when it does this. I'd like to stop that warning.

I've tried a few times to get a patch like this one through, so far with no

I would like to either remove the specification if it's not required by
anybody anymore (which this patch tries) or add an alternate path for MSVC.
I tried the alternate path option for MSVC in previous patches but they
never got traction or at least committed by anyone.

So this patch tries the path of removing the bad_alloc exception spec for
new for all platforms.

I'm sure everyone will correct me if I'm wrong, but my thinking is that
this will be ok, because a function that has no exception spec can throw
anything making them equivalent to throw(...), and exception specifications
are deprecated anyway. So can we just remove them for this function as this
patch does?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140107/e637fc70/attachment.html>
-------------- next part --------------
Index: new
--- new	(revision 198593)
+++ new	(working copy)
@@ -124,20 +124,12 @@
-_LIBCPP_NEW_DELETE_VIS void* operator new(std::size_t __sz)
-#if !__has_feature(cxx_noexcept)
-    throw(std::bad_alloc)
+_LIBCPP_NEW_DELETE_VIS void* operator new(std::size_t __sz);
 _LIBCPP_NEW_DELETE_VIS void* operator new(std::size_t __sz, const std::nothrow_t&) _NOEXCEPT _NOALIAS;
 _LIBCPP_NEW_DELETE_VIS void  operator delete(void* __p) _NOEXCEPT;
 _LIBCPP_NEW_DELETE_VIS void  operator delete(void* __p, const std::nothrow_t&) _NOEXCEPT;
-_LIBCPP_NEW_DELETE_VIS void* operator new[](std::size_t __sz)
-#if !__has_feature(cxx_noexcept)
-    throw(std::bad_alloc)
+_LIBCPP_NEW_DELETE_VIS void* operator new[](std::size_t __sz);
 _LIBCPP_NEW_DELETE_VIS void* operator new[](std::size_t __sz, const std::nothrow_t&) _NOEXCEPT _NOALIAS;
 _LIBCPP_NEW_DELETE_VIS void  operator delete[](void* __p) _NOEXCEPT;
 _LIBCPP_NEW_DELETE_VIS void  operator delete[](void* __p, const std::nothrow_t&) _NOEXCEPT;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: new.cpp
Type: text/x-c++src
Size: 4358 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140107/e637fc70/attachment.cpp>

More information about the cfe-commits mailing list