[llvm-commits] [llvm] r135391 - /llvm/trunk/include/llvm/ADT/ArrayRef.h
Frits van Bommel
fvbommel at gmail.com
Mon Jul 18 07:36:36 PDT 2011
2011/7/18 David Blaikie <dblaikie at gmail.com>:
>> template<typename T, size_t N>
>> ArrayRef<T> makeArrayRef(const T (&Arr)[N]) {
>> - return Arr;
>> + return ArrayRef<T>(Arr, N);
>> }
>
> If you're going to implement this specialization this way you could probably
> just remove the ArrayRef(const T(&)[N]) ctor entirely since no one
> should/will ever use it. Alternatively would "return ArrayRef<T>(Arr)" avoid
> the pointer degeneration? (& if that ctor doesn't work correctly (even if
Actually, the constructor will still be used for implicit conversions
from arrays, which are used in man places in the tree still.
I don't know if the version with an explicit constructor but implicit
length will work, I just committed this blindly to fix it (I didn't
have time to try it with GCC myself).
> it's just because of a misimplementation* on a mainstream compiler)
> implicitly, should we just mark it explicit to be on the safe side?)
As I said, the constructor seems to work fine for the many implicit
conversions from arrays, so there's no need to mark it explicit. The
problem seems to be specific to array reference parameter --> ArrayRef
conversion as in this function.
> * is this a bug in GCC? filed somewhere?
No idea, I've been a bit too busy today to investigate.
More information about the llvm-commits
mailing list