[PATCH] D48342: [libcxx] Optimize vectors construction of trivial types from an iterator range with const-ness mismatch.

Volodymyr Sapsai via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Jan 7 16:10:01 PST 2019


vsapsai added inline comments.


================
Comment at: libcxx/test/std/containers/sequences/vector/vector.cons/construct_iter_iter.pass.cpp:161
+  {
+    // Though types are different, initialization can be done with `memcpy`.
+    int32_t array[1] = {-1};
----------------
Quuxplusone wrote:
> vsapsai wrote:
> > Quuxplusone wrote:
> > > I might add "can be, but currently isn't, done with memcpy."
> > > 
> > > Here's my other suggested test:
> > > 
> > > ```
> > > struct X { int x; };
> > > struct Y { int y; };
> > > struct Z : X, Y { int z; };
> > > {
> > >     Z z;
> > >     Z *array[1] = { &z };
> > >     // Though the types Z* and Y* are very similar, initialization still cannot be done with memcpy.
> > >     std::vector<Y*> v(array, array + 1);
> > >     assert(v[0] == &z);
> > > }
> > > ```
> > Thanks, I'll try your `XYZ` test, looks like it should help with my `iostream*/ostream*` struggles.
> LGTM! Ship it!
> (I'm surprised the structs can be defined inside the body of `main()` like that, but I have no objection to doing so.)
I've decided not to add "can be, but currently isn't, done with memcpy" because I don't believe that comment will be kept up to date.

Thanks for all the rounds of review, Arthur.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D48342





More information about the cfe-commits mailing list