It seems like ArrayRefs are supposed to be immutable (
However, as far as i can tell, the iterators are defined wrong to make this true.
While
ArrayRef Foo(Something);
Foo[0] = 5;
will give a compile time error.
something like:
ArrayRef Foo(Something);
std::sort(Foo.begin(), Foo.end());
Will work fine.
Is this expected?
(FWIW: I expected this to only work with a MutableArrayRef)
rnk
October 1, 2017, 12:35am
#2
It wraps a constant T* and a size_t, so I’m surprised std::sort works. It shouldn’t.
+1, totally a bug. That’s the domain of MutableArrayRef.
-Chris
It’s possible I’m missing something, but I can’t reproduce this:
std::vector A = { 4, 15, 42 , 16, 8, 23};
ArrayRef B(A);
std::sort(B.begin(), B.end());
fails to compile for me.
ArrayRef::iterator is specified as const T *
, so I’m not seeing how this could happen?
It's possible I'm missing something, but I can't reproduce this:
std::vector<int> A = { 4, 15, 42 , 16, 8, 23};
ArrayRef<int> B(A);
std::sort(B.begin(), B.end());
fails to compile for me.
As later mentioned, it was transient and appears to have only affected some
version
Because of that, i stopped looking into it after tracking it down to what
appears to be a hilarious miscompile of clang.