[libcxx-commits] [PATCH] D59572: Fix and speedup __libcpp_locale_guard on Windows

Marshall Clow via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Tue Mar 26 19:17:35 PDT 2019

mclow.lists added inline comments.

Comment at: include/__locale:96
+      const char* __new_locale = setlocale(LC_ALL, __locale);
+      if (__new_locale == nullptr)
+        __throw_bad_alloc();
thomasanderson wrote:
> mclow.lists wrote:
> > I really doubt that this is going to work for anyone who builds with exceptions disabled.
> > 
> > On the other hand, maybe that's "not a thing" on windows and/or mingw.
> Looks like `__throw_bad_alloc()` calls `std::abort()` if building without exceptions.  (Also there's similar unguarded calls to `__throw_bad_alloc()` in eg. `include/locale`)
This is completely my bad. I was wrong here.

I read this as `throw bad_alloc`, which will not work with exceptions disabled.
`__throw_bad_alloc`, on the other hand, will work fine.



More information about the libcxx-commits mailing list