[Issue 16455] Wrong code when calling a struct delegate

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Wed Aug 31 14:51:42 PDT 2016


https://issues.dlang.org/show_bug.cgi?id=16455

ag0aep6g at gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |ag0aep6g at gmail.com
         Resolution|---                         |INVALID

--- Comment #1 from ag0aep6g at gmail.com ---
(In reply to apham from comment #0)
> struct NodeRange(S)
> {
[...]
>     void delegate() doPopFront;
> 
>     void doMove()
>     {
[...]
>     }
[...]
>     this(Node!S aParent)
>     {
[...]
>         doPopFront = &doMove;
>     }
[...]
> }

As far as I see, that code is invalid. &doMove refers to the current location
of the struct. But structs can be copied and moved around (the compiler is even
allowed to do it on its own). Whenever that happens, doPopFront is invalidated.

Closing as invalid. Please reopen if you disagree.

--


More information about the Digitalmars-d-bugs mailing list