Re: Classical bug

2015-01-27 Thread Fyodor Ustinov via Digitalmars-d-learn
On Tuesday, 27 January 2015 at 12:02:59 UTC, Vladimir Panteleev wrote: 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; } I think this is the first step of a long and difficult way. by

Re: Classical bug

2015-01-27 Thread bearophile via Digitalmars-d-learn
Vladimir Panteleev: But the check seems very simple, and is easily circumvented. This compiles: byte[] func() { byte[1024] buffer; auto p = buffer[0..3]; return p; } I guess such bugs will be detected (in safe code only!) after the implementation of: http://wiki.dlang.org/DIP69 Currently

Re: Classical bug

2015-01-27 Thread Fyodor Ustinov via Digitalmars-d-learn
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?

Re: Classical bug

2015-01-27 Thread Vladimir Panteleev via Digitalmars-d-learn
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

Re: Classical bug

2015-01-27 Thread Vladimir Panteleev via Digitalmars-d-learn
On Tuesday, 27 January 2015 at 11:41:21 UTC, Fyodor Ustinov wrote: byte[] func() @safe { byte[1024] buffer; return buffer[0..3]; } void main() { auto b = func(); b[0] = 1; } In 2.067, this is an error: test.d(4,9): Error: escaping reference to local variable buffer

Classical bug

2015-01-27 Thread Fyodor Ustinov via Digitalmars-d-learn
Hi! I thought at least in safe mode this code will not compile or I get warning: byte[] func() @safe { byte[1024] buffer; return buffer[0..3]; } void main() { auto b = func(); b[0] = 1; } But no any error. Dlang do not catch this? WBR, Fyodor.