Thread overview
[Issue 12932] Support @nogc for immediately iterated array literal
Jun 16, 2014
Kenji Hara
Jun 16, 2014
Kenji Hara
Jun 16, 2014
Kenji Hara
June 16, 2014
https://issues.dlang.org/show_bug.cgi?id=12932

Kenji Hara <k.hara.pg@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull

--- Comment #1 from Kenji Hara <k.hara.pg@gmail.com> ---
https://github.com/D-Programming-Language/dmd/pull/3673

--
June 16, 2014
https://issues.dlang.org/show_bug.cgi?id=12932

bearophile_hugs@eml.cc changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bearophile_hugs@eml.cc

--- Comment #2 from bearophile_hugs@eml.cc ---
This seems a nice improvement (if it's safe).

--
June 16, 2014
https://issues.dlang.org/show_bug.cgi?id=12932

--- Comment #3 from github-bugzilla@puremagic.com ---
Commits pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/dfb44a6d1f851eb9048ef459bf075f953a290fbf fix Issue 12932 - Support @nogc for immediately iterated array literal

https://github.com/D-Programming-Language/dmd/commit/e719a3662657d58a2efeceff444b844eb0be1dcf Merge pull request #3673 from 9rnsr/fix12932

Issue 12932 - Support @nogc for immediately iterated array literal

--
June 16, 2014
https://issues.dlang.org/show_bug.cgi?id=12932

--- Comment #4 from bearophile_hugs@eml.cc ---
Currently this gets rejected, is this right?

void main() @nogc {
    foreach (       a; [[1]]) {}
    foreach (int[1] a; [[1]]) {}
}


test.d(2): Error: array literal in @nogc function main may cause GC allocation
test.d(3): Error: array literal in @nogc function main may cause GC allocation

--
June 16, 2014
https://issues.dlang.org/show_bug.cgi?id=12932

--- Comment #5 from bearophile_hugs@eml.cc ---
A better example:

struct F { int x; }
void main() @nogc {
    foreach (       a; [[1]]) {}  // Error
    foreach (int[1] a; [[1]]) {}  // Error
    foreach (       a; [F(1)]) {} // OK
}

--
June 16, 2014
https://issues.dlang.org/show_bug.cgi?id=12932

--- Comment #6 from Kenji Hara <k.hara.pg@gmail.com> ---
(In reply to bearophile_hugs from comment #4)
> Currently this gets rejected, is this right?
> 
> void main() @nogc {
>     foreach (       a; [[1]]) {}
>     foreach (int[1] a; [[1]]) {}
> }
> 
> 
> test.d(2): Error: array literal in @nogc function main may cause GC
> allocation
> test.d(3): Error: array literal in @nogc function main may cause GC
> allocation

My PR does not support complex case. It would need more thought to improve the feature.

--
June 16, 2014
https://issues.dlang.org/show_bug.cgi?id=12932

--- Comment #7 from bearophile_hugs@eml.cc ---
(In reply to Kenji Hara from comment #6)

> My PR does not support complex case. It would need more thought to improve the feature.

OK. Do you want me to open another enhancement request, or do you want me to reopen this one, or do you think this improved feature is not worth implementing?

--
June 16, 2014
https://issues.dlang.org/show_bug.cgi?id=12932

--- Comment #8 from Kenji Hara <k.hara.pg@gmail.com> ---
(In reply to bearophile_hugs from comment #7)
> OK. Do you want me to open another enhancement request, or do you want me to reopen this one, or do you think this improved feature is not worth implementing?

If possible, I'd like to improve things. But it would need more time. Therefore openeng new encancement is the best.

--
June 16, 2014
https://issues.dlang.org/show_bug.cgi?id=12932

--- Comment #9 from bearophile_hugs@eml.cc ---
(In reply to Kenji Hara from comment #8)
> (In reply to bearophile_hugs from comment #7)
> > OK. Do you want me to open another enhancement request, or do you want me to reopen this one, or do you think this improved feature is not worth implementing?
> 
> If possible, I'd like to improve things. But it would need more time. Therefore openeng new encancement is the best.

OK, Issue 12936

--