[patch] [libcxx] new/.cpp trivial warning fix.

G M gmisocpp at gmail.com
Thu Oct 24 19:13:34 PDT 2013


Hi
I don't understand this code:

 _LIBCPP_NEW_DELETE_VIS void* operator new(std::size_t __sz)
 #if !__has_feature(cxx_noexcept)
+#if defined(_LIBCPP_MSVC)
+    throw(...)
+#else
     throw(std::bad_alloc)
 #endif
+#endif
 ;

Are you anticipating that operator new will throw things other than
std::bad_alloc?
Or does MSVC just hate exception specifications?
[ I'm not really that fond of them, but still …. ]

Yes I thought the code was a bit weird to begin with too. I'm just adding
more of the same. But I think the logic is something like, "exception
specifications are deprecated/going away, if the compiler is aware that we
don't need them, don't use them. If the compiler isn't aware that we don't
need them, use what we know works. for clang that's throw x; meaning we
throw x; for msvc that's throw(...) meaning say we throw something, but I
don't know what and don't support a meaning of saying what.".

It's the only place this type of thing is used, so there isn't any
value supporting some kind of clever macro for that. The whole ugliness
will go away for all compilers soon enough I think.
-- Marshall
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20131025/c741e59f/attachment.html>


More information about the cfe-commits mailing list