<div dir="rtl"><div dir="ltr"><span style="font-size:12.8000001907349px">+<a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a></span></div><div dir="ltr"><span style="font-size:12.8000001907349px"><br></span></div><div dir="ltr"><span style="font-size:12.8000001907349px">gcc 4.8 fails the unit test, see the bots.</span><br></div><div dir="ltr"><span style="font-size:12.8000001907349px"><br></span></div><div class="gmail_extra" dir="ltr"><br><div class="gmail_quote"><div>2015-08-04 18:52 GMT+03:00 Benjamin Kramer <span dir="ltr"><<a href="mailto:benny.kra@googlemail.com" target="_blank">benny.kra@googlemail.com</a>></span>:</div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">Author: d0k<br>
Date: Tue Aug 4 10:52:56 2015<br>
New Revision: 243995<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=243995&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=243995&view=rev</a><br>
Log:<br>
[ArrayRef] Make copy use std::uninitialized_copy.<br>
<br>
std::copy does not work for non-trivially copyable classes when we're<br>
copying into uninitialized memory.<br>
<br>
Modified:<br>
llvm/trunk/include/llvm/ADT/ArrayRef.h<br>
llvm/trunk/unittests/ADT/ArrayRefTest.cpp<br>
<br>
Modified: llvm/trunk/include/llvm/ADT/ArrayRef.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/ArrayRef.h?rev=243995&r1=243994&r2=243995&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/ArrayRef.h?rev=243995&r1=243994&r2=243995&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/include/llvm/ADT/ArrayRef.h (original)<br>
+++ llvm/trunk/include/llvm/ADT/ArrayRef.h Tue Aug 4 10:52:56 2015<br>
@@ -148,7 +148,7 @@ namespace llvm {<br>
// copy - Allocate copy in Allocator and return ArrayRef<T> to it.<br>
template <typename Allocator> ArrayRef<T> copy(Allocator &A) {<br>
T *Buff = A.template Allocate<T>(Length);<br>
- std::copy(begin(), end(), Buff);<br>
+ std::uninitialized_copy(begin(), end(), Buff);<br>
return ArrayRef<T>(Buff, Length);<br>
}<br>
<br>
<br>
Modified: llvm/trunk/unittests/ADT/ArrayRefTest.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/ADT/ArrayRefTest.cpp?rev=243995&r1=243994&r2=243995&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/ADT/ArrayRefTest.cpp?rev=243995&r1=243994&r2=243995&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/unittests/ADT/ArrayRefTest.cpp (original)<br>
+++ llvm/trunk/unittests/ADT/ArrayRefTest.cpp Tue Aug 4 10:52:56 2015<br>
@@ -31,7 +31,7 @@ static_assert(<br>
!std::is_convertible<ArrayRef<volatile int *>, ArrayRef<int *>>::value,<br>
"Removing volatile");<br>
<br>
-namespace llvm {<br>
+namespace {<br>
<br>
TEST(ArrayRefTest, AllocatorCopy) {<br>
BumpPtrAllocator Alloc;<br>
@@ -45,6 +45,18 @@ TEST(ArrayRefTest, AllocatorCopy) {<br>
EXPECT_NE(Array1.data(), Array1c.data());<br>
EXPECT_TRUE(Array2.equals(Array2c));<br>
EXPECT_NE(Array2.data(), Array2c.data());<br>
+<br>
+ // Check that copy can cope with uninitialized memory.<br>
+ struct NonAssignable {<br>
+ const char *Ptr;<br>
+<br>
+ NonAssignable(const NonAssignable &RHS) = default;<br>
+ void operator=(const NonAssignable &RHS) { assert(RHS.Ptr != nullptr); }<br>
+ bool operator==(const NonAssignable &RHS) const { return Ptr == RHS.Ptr; }<br>
+ } Array3Src[] = {{"hello"}, {"world"}};<br>
+ ArrayRef<NonAssignable> Array3Copy = makeArrayRef(Array3Src).copy(Alloc);<br>
+ EXPECT_EQ(makeArrayRef(Array3Src), Array3Copy);<br>
+ EXPECT_NE(makeArrayRef(Array3Src).data(), Array3Copy.data());<br>
}<br>
<br>
TEST(ArrayRefTest, DropBack) {<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
</blockquote></div><br></div></div>