Classical bug

Vladimir Panteleev via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Jan 27 04:02:58 PST 2015


On Tuesday, 27 January 2015 at 12:01:11 UTC, Fyodor Ustinov wrote:
> On Tuesday, 27 January 2015 at 11:51:43 UTC, Vladimir Panteleev 
> wrote:
>> In 2.067, this is an error:
>>
>> test.d(4,9): Error: escaping reference to local variable buffer
>
> Always or only in safe mode?

Always. But the check seems very simple, and is easily 
circumvented. This compiles:

byte[] func() {
  byte[1024] buffer;
  auto p = buffer[0..3];
  return p;
}


More information about the Digitalmars-d-learn mailing list