[Issue 3024] Array slicing allows returning an escaping reference to a local stack variable

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Apr 21 12:57:44 UTC 2018


https://issues.dlang.org/show_bug.cgi?id=3024

Nick Treleaven <nick at geany.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |nick at geany.org
         Resolution|---                         |FIXED

--- Comment #3 from Nick Treleaven <nick at geany.org> ---
(In reply to david from comment #0)
> byte[] func2()
> {
> 	byte[16] v= [65,65,65,65,
> 		     65,65,65,65,
> 		     65,65,65,65,
> 		     65,65,65,65];
> 	return v[0..16];
> }

This is now fixed (dmd v2.079.1):

onlineapp.d(7): Error: returning v[0..16] escapes a reference to local variable
v

--


More information about the Digitalmars-d-bugs mailing list