Thread overview
[Issue 16362] `foreach (ref v; range)` with non-ref returning `.front()` missing dtors
Aug 08, 2016
Ketmar Dark
Aug 08, 2016
Ketmar Dark
Aug 10, 2016
Ketmar Dark
Dec 17, 2022
Iain Buclaw
May 30, 2023
RazvanN
August 08, 2016
https://issues.dlang.org/show_bug.cgi?id=16362

Ketmar Dark <ketmar@ketmar.no-ip.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ketmar@ketmar.no-ip.org

--
August 08, 2016
https://issues.dlang.org/show_bug.cgi?id=16362

--- Comment #1 from Ketmar Dark <ketmar@ketmar.no-ip.org> ---
Created attachment 1607
  --> https://issues.dlang.org/attachment.cgi?id=1607&action=edit
fix and test case

this patch fixes the issue by dropping `ref` from foreach args if `.front` is function, and it doesn't return by reference.

with trivial change this patch can also be used to resolve issue 11934.

--
August 10, 2016
https://issues.dlang.org/show_bug.cgi?id=16362

Ketmar Dark <ketmar@ketmar.no-ip.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Attachment #1607|0                           |1
        is obsolete|                            |

--- Comment #2 from Ketmar Dark <ketmar@ketmar.no-ip.org> ---
Created attachment 1608
  --> https://issues.dlang.org/attachment.cgi?id=1608&action=edit
fix and test case, v2

remove `ref` only for types that needs dtor to be called. this *may* give some speedup when `.front` returns structs without dtors.

--
December 17, 2022
https://issues.dlang.org/show_bug.cgi?id=16362

Iain Buclaw <ibuclaw@gdcproject.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P1                          |P2

--
May 30, 2023
https://issues.dlang.org/show_bug.cgi?id=16362

RazvanN <razvan.nitu1305@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |razvan.nitu1305@gmail.com
         Resolution|---                         |WORKSFORME

--- Comment #3 from RazvanN <razvan.nitu1305@gmail.com> ---
This seems to have been fixed. Using latest master I was able to compile the code and run it successfully.

--