incorrect data when returning static array in place of dynamic

anonymous via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Jul 6 03:20:26 PDT 2015


On Monday, 6 July 2015 at 07:48:17 UTC, sigod wrote:
> Aren't compiler smart enough to prevent it?
>
> ```
> ubyte[] test1()
> {
> 	auto b = sha1Of("");
>
> 	return b; // Error: escaping reference to local b
> }
>
> ubyte[] test2()
> {
> 	return sha1Of(""); // works, but returns incorrect data
> }
> ```
>
> Looks more like a bug to me.

dmd 2.068.0 catches this. You can get the beta here:
http://downloads.dlang.org/pre-releases/2.x/2.068.0/


More information about the Digitalmars-d-learn mailing list