[libcxx-commits] [PATCH] D132149: [String] Allow fancy pointer as pointer type of basic_string allocator

Nikolas Klauser via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Wed Dec 21 06:04:40 PST 2022


philnik added a comment.

I think you misunderstood what I was asking for regarding the tests. I wanted you to move the refactoring into it's own patch, so that the test changes here would be just a single line per test.



================
Comment at: libcxx/include/string:778
 
+#ifdef _LIBCPP_CXX03_LANG
     union __ulx{__long __lx; __short __lxx;};
----------------
bemeryesr wrote:
> philnik wrote:
> > Why is this special-casing needed? AFAICT the code below is valid in C++03.
> This is needed because the C++03 standard says "An object of a class with a non-trivial default constructor (12.1), a non-trivial copy constructor (12.8), a non-trivial destructor (12.4), or a non-trivial copy assignment operator (13.5.3, 12.8) cannot be a member of a union". Since __long contains a fancy pointer which is not trivially constructible, __long itself is not trivially constructible and therefore __rep cannot include it as a member in C++03. 
That doesn't change anything between the two versions though. C++03 doesn't work with fancy pointers either way. Actually, why do we need a default constructor in the union at all?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D132149/new/

https://reviews.llvm.org/D132149



More information about the libcxx-commits mailing list