diff --git a/src/core/internal/convert.d b/src/core/internal/convert.d index ebda8992347..66d3016dd8a 100644 --- a/src/core/internal/convert.d +++ b/src/core/internal/convert.d @@ -479,7 +479,7 @@ const(ubyte)[] toUbyte(T)(T[] arr) if (T.sizeof == 1) } @trusted pure nothrow -const(ubyte)[] toUbyte(T)(T[] arr) if ((is(typeof(toUbyte(arr[0])) == const(ubyte)[]))&&(T.sizeof > 1)) +const(ubyte)[] toUbyte(T)(T[] arr) if ((is(typeof(toUbyte(arr[0])) == const(ubyte)[])) && (T.sizeof > 1)) { if (__ctfe) { @@ -514,7 +514,7 @@ const(ubyte)[] toUbyte(T)(ref T val) if (__traits(isIntegral, T) && !is(T == enu { ubyte[T.sizeof] tmp; Unqual!T val_ = val; - for (size_t i=0; i>= 8; } - - return tmp[]; - + return tmp[].dup; } else { @@ -628,7 +626,7 @@ const(ubyte)[] toUbyte(T)(ref T val) if (is(T == struct) || is(T == union)) assert(0, "Unable to compute byte representation of "~typeof(CUR_TYPE).stringof~" field at compile time"); } } - return bytes[]; + return bytes[].dup; } else {