strange bug with unions?

Vladimir Panteleev via Digitalmars-d digitalmars-d at puremagic.com
Fri May 29 01:32:26 PDT 2015


On Friday, 29 May 2015 at 07:55:55 UTC, seen wrote:
> ubyte[] toBytes(T)(T from) if (!is(T == const))
> {
> 	ByteConverter!T converter;
> 	converter.value = from;
> 	return converter.bytes;
> }

This function is incorrect: it is returning a slice (dynamic 
array) of a static array, which is located on the stack. The fact 
that it compiles without error is bug 9279 
(https://issues.dlang.org/show_bug.cgi?id=9279).


More information about the Digitalmars-d mailing list