[libcxx-commits] [PATCH] D65667: [libcxx] Avoid destructor call for error_category singletons

Marshall Clow via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Fri Aug 16 16:04:00 PDT 2019

mclow.lists added inline comments.

Comment at: libcxx/src/system_error.cpp:202
+union GenericAndSystemErrorHelper {
+  struct {
+    __generic_error_category new_generic_error_category;
hubert.reinterpretcast wrote:
> mclow.lists wrote:
> > Why do you overlay both of these in a single structure?
> > 
> > Is your intent that a program only calls either `generic_category` or `system_category` in any particular run of the program? Otherwise, don't you get UB?
> > 
> These aren't overlaid, but it does mean that there would be an unused instance of one of the types for each helper we create. We should probably avoid that.
Sorry, I misread the union/struct nesting.  You are correct.



More information about the libcxx-commits mailing list