Jump to page: 1 2
Thread overview
[Issue 11044] Escaping references to lazy argument are allowed
May 01, 2017
Nick Treleaven
Jan 25, 2018
Carsten Blüggel
[Issue 11044] Escaping references to lazy argument are allowed and compile to wrong code
Sep 21, 2018
Vladimir Panteleev
May 16, 2019
ag0aep6g
Mar 04, 2020
Walter Bright
Apr 04, 2020
Walter Bright
Jul 14, 2022
RazvanN
Jan 15, 2023
Adam D. Ruppe
Jun 05, 2023
Vladimir Panteleev
Jun 05, 2023
Vladimir Panteleev
June 09, 2015
https://issues.dlang.org/show_bug.cgi?id=11044

Andrei Alexandrescu <andrei@erdani.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Version|unspecified                 |D2

--
May 01, 2017
https://issues.dlang.org/show_bug.cgi?id=11044

Nick Treleaven <nick@geany.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |safe
                 CC|                            |nick@geany.org

--- Comment #2 from Nick Treleaven <nick@geany.org> ---
With dmd 2.074, -dip1000 the `dg = { return i; }` from comment 1 won't compile, but the original lazy code still does.

--
January 25, 2018
https://issues.dlang.org/show_bug.cgi?id=11044

Carsten Blüggel <chilli@posteo.net> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |chilli@posteo.net

--
September 21, 2018
https://issues.dlang.org/show_bug.cgi?id=11044

Vladimir Panteleev <dlang-bugzilla@thecybershadow.net> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |wrong-code
            Summary|Escaping references to lazy |Escaping references to lazy
                   |argument are allowed        |argument are allowed and
                   |                            |compile to wrong code
           Severity|normal                      |critical

--- Comment #3 from Vladimir Panteleev <dlang-bugzilla@thecybershadow.net> ---
Another test case:

///////////// test.d ////////////
@safe:

auto toDg(E)(lazy E value)
{
    return { return value; };
}

C t;

class C
{
    auto getDg()
    {
        // return () => prop;
        return toDg(prop);
    }

    final @property string prop()
    {
        assert(this is t);
        return null;
    }
}

void smashStack() {
    int[1024] dummy = 0xcafebabe;
}


void main()
{
    t = new C();
    auto result = t.getDg();
    smashStack();
    result();
}
/////////////////////////////////

The compiler needs to either reject the code (accepts-invalid), or generate a
closure (wrong-code).

Upgrading severity as this can manifest as a latent bug (depending on whether the stack was overwritten or not) in @safe code.

--
May 16, 2019
https://issues.dlang.org/show_bug.cgi?id=11044

ag0aep6g <ag0aep6g@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |simen.kjaras@gmail.com

--- Comment #4 from ag0aep6g <ag0aep6g@gmail.com> ---
*** Issue 19880 has been marked as a duplicate of this issue. ***

--
March 04, 2020
https://issues.dlang.org/show_bug.cgi?id=11044

Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bugzilla@digitalmars.com

--- Comment #5 from Walter Bright <bugzilla@digitalmars.com> ---
I have a dip in the works to deprecate lazy parameters, replacing them with delegates, precisely because of problems like this. So this particular issue will likely not get fixed.

--
April 04, 2020
https://issues.dlang.org/show_bug.cgi?id=11044

--- Comment #6 from Walter Bright <bugzilla@digitalmars.com> ---
I recommend in the meantime replacing the lazy parameter with a delegate.

--
July 14, 2022
https://issues.dlang.org/show_bug.cgi?id=11044

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

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

--
January 15, 2023
https://issues.dlang.org/show_bug.cgi?id=11044

Adam D. Ruppe <destructionator@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |destructionator@gmail.com

--- Comment #7 from Adam D. Ruppe <destructionator@gmail.com> ---
lazy lowers to delegate, so it should be easy to just lower to the right kind of delegate and get correct behavior. There was a dconf online talk about this in 2022.

--
June 05, 2023
https://issues.dlang.org/show_bug.cgi?id=11044

Vladimir Panteleev <dlang-bugzilla@thecybershadow.net> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
                 CC|                            |dlang-bugzilla@thecybershad
                   |                            |ow.net
         Resolution|WONTFIX                     |---

--- Comment #8 from Vladimir Panteleev <dlang-bugzilla@thecybershadow.net> ---
(In reply to Walter Bright from comment #5)
> I have a dip in the works to deprecate lazy parameters, replacing them with delegates, precisely because of problems like this. So this particular issue will likely not get fixed.

Looks like this was not an easy decision to make, as the situation is unchanged three years later. I think we should at least do something about bugs like this in the meantime - the compiler should either reject such constructs or not generate bad code for them.

Personally I am skeptical that lazy can be removed from the language at this point, because for one thing doing so will break std.exception.enforce, and make it impossible to wrap or implement assert in user code. As far as I can see, we have no choice but to support it as part of the language going forward.

--
« First   ‹ Prev
1 2