Thread overview | |||||
---|---|---|---|---|---|
|
May 06, 2015 false positive escaping reference to local array | ||||
---|---|---|---|---|
| ||||
Hi all, Please consider the following program: void main() { int array[13]; int[] internalFunc() { return array; } } This code does not compile (dmd 2.066.1), claiming: test.d(5): Error: escaping reference to local array The way I see it, the array in question is in scope anywhere the function is, and as such, this error is a false positive. Thoughts? Shachar |
May 06, 2015 Re: false positive escaping reference to local array | ||||
---|---|---|---|---|
| ||||
Posted in reply to Shachar Shemesh | On Wednesday, 6 May 2015 at 07:28:30 UTC, Shachar Shemesh wrote:
> Hi all,
>
> Please consider the following program:
> void main() {
> int array[13];
>
> int[] internalFunc() {
> return array;
> }
> }
>
> This code does not compile (dmd 2.066.1), claiming:
> test.d(5): Error: escaping reference to local array
>
> The way I see it, the array in question is in scope anywhere the function is, and as such, this error is a false positive.
>
> Thoughts?
>
> Shachar
compiles fine in 2.067.
|
May 06, 2015 Re: false positive escaping reference to local array | ||||
---|---|---|---|---|
| ||||
Posted in reply to Shachar Shemesh | On 06/05/15 10:28, Shachar Shemesh wrote:
> Hi all,
>
> Please consider the following program:
> void main() {
> int array[13];
>
> int[] internalFunc() {
> return array;
> }
> }
>
> This code does not compile (dmd 2.066.1), claiming:
> test.d(5): Error: escaping reference to local array
>
> The way I see it, the array in question is in scope anywhere the
> function is, and as such, this error is a false positive.
>
> Thoughts?
>
> Shachar
Interestingly, adding neither @system nor @trusted to the inner function solves this problem.
Shachar
|
Copyright © 1999-2021 by the D Language Foundation