Jump to page: 1 2
Thread overview
[Issue 8269] The 'with statement' does not observe temporary object lifetime
Jul 11, 2014
Denis Shelomovskij
Jul 29, 2014
yebblies
Jul 30, 2014
yebblies
Jul 30, 2014
yebblies
Aug 08, 2014
Orvid King
Aug 09, 2014
yebblies
Aug 09, 2014
Damian
Aug 09, 2014
yebblies
Aug 09, 2014
Orvid King
Aug 10, 2014
yebblies
July 11, 2014
https://issues.dlang.org/show_bug.cgi?id=8269

Denis Shelomovskij <verylonglogin.reg@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |wrong-code
                 CC|                            |verylonglogin.reg@gmail.com
           Severity|normal                      |major

--- Comment #5 from Denis Shelomovskij <verylonglogin.reg@gmail.com> ---
Smaller testcase:
---
struct S
{
    bool alive = true;

    ~this() { alive = false; }
}

void main()
{
    with(S()) // <-- `S` is created and destructed here
        assert(alive); // fails
}
---

This is a major issue as it breaks RAII.

--
July 29, 2014
https://issues.dlang.org/show_bug.cgi?id=8269

yebblies <yebblies@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|preapproved                 |
                 CC|                            |yebblies@gmail.com

--
July 29, 2014
https://issues.dlang.org/show_bug.cgi?id=8269

--- Comment #6 from Andrei Alexandrescu <andrei@erdani.com> ---
@yebblies: why did you remove the "preapproved" tag?

--
July 30, 2014
https://issues.dlang.org/show_bug.cgi?id=8269

--- Comment #7 from yebblies <yebblies@gmail.com> ---
(In reply to Andrei Alexandrescu from comment #6)
> @yebblies: why did you remove the "preapproved" tag?

I don't see the point of it on a wrong code bug.  Either the bug is valid and it will be fixed, or it isn't and it won't.

--
July 30, 2014
https://issues.dlang.org/show_bug.cgi?id=8269

--- Comment #8 from Andrei Alexandrescu <andrei@erdani.com> ---
I see - fine. I was hoping to boost its visibility :o).

--
July 30, 2014
https://issues.dlang.org/show_bug.cgi?id=8269

--- Comment #9 from yebblies <yebblies@gmail.com> ---
(In reply to Andrei Alexandrescu from comment #8)
> I see - fine. I was hoping to boost its visibility :o).

I can't speak for the other dmd contributors, but I never look at the preapproved list.  I will look at the ice and wrong-code lists when I'm in that kind of mood.

If you really want to boost its profile, tou could try putting a big bounty on it :D

This is actually a perfect example of a good bug for a bounty - it is non-controversial, and has a small, well-defined scope.  It's almost entirely debugging and implementation.

Anyway, it's next on my list, assuming I don't get distracted.  As Andrej noted the implementation of 'with' is a big weird and needs some work.

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

Andrei Alexandrescu <andrei@erdani.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |bounty

--- Comment #10 from Andrei Alexandrescu <andrei@erdani.com> ---
@yebblies: good idea! https://www.bountysource.com/issues/3635875-the-with-statement-does-not-observe-temporary-object-lifetime

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

--- Comment #11 from Orvid King <blah38621@gmail.com> ---
I would suspect that this is likely because of how the with statement currently expands itself, although it's certainly possible that it's e2ir (though I don't think it actually is present at the e2ir layer, was about to check that)

--
August 09, 2014
https://issues.dlang.org/show_bug.cgi?id=8269

yebblies <yebblies@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull
           Assignee|nobody@puremagic.com        |yebblies@gmail.com

--- Comment #12 from yebblies <yebblies@gmail.com> ---
It is how it expands itself.

with(exp) {...} gets re-written to

with(auto tmp = exp, tmp) {...}

and then

with(auto withptr = &(auto tmp = exp, tmp)) {...}

which ends up looking like

auto withptr = &(auto tmp = exp, tmp)
...

in the glue layer.  Since tmp is local to the expression, the dtor code is inserted right after it.

https://github.com/D-Programming-Language/dmd/pull/3855

--
August 09, 2014
https://issues.dlang.org/show_bug.cgi?id=8269

Damian <damianday@hotmail.co.uk> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |damianday@hotmail.co.uk

--- Comment #13 from Damian <damianday@hotmail.co.uk> ---
Why would the with statement be creating a temporary in the first place? It seems terribly inefficient, surely it can just alias the original object and be done with it?

--
« First   ‹ Prev
1 2