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

--- Comment #14 from yebblies <yebblies@gmail.com> ---
(In reply to Damian from comment #13)
> 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?

It does when it can, but it can't when the with argument is an rvalue.

eg

Struct generateStructForMe() { ... }

with(generateStructForMe())
{
   auto x = member1 + member2;
}

You want this to expand to (and in lvalue cases it will)

auto withptr = &generateStructForMe();
auto x = withptr.member1 + withptr.member2;

But this can't work, because the struct has to be stored somewhere before you can take its address.

The struct literals in these examples are also rvalues and work the same way. Class references and struct pointers do not have this problem an can be copied freely.

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

Orvid King <blah38621@gmail.com> changed:

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

--- Comment #15 from Orvid King <blah38621@gmail.com> ---
What does it do about postblits in this case?

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

--- Comment #16 from yebblies <yebblies@gmail.com> ---
(In reply to Orvid King from comment #15)
> What does it do about postblits in this case?

The same thing that happens with

auto tmp = someRvalue();
with(tmp)
{
}

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

--- Comment #17 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/4321a856bd1e3ed1aa0fe5e613a658ad192c9e86
Fix Issue 8269 - The 'with statement' does not observe temporary object
lifetime

https://github.com/D-Programming-Language/dmd/commit/839f2e1bc929ba3055c4d64c022a5f98fa7225c5 Merge pull request #3855 from yebblies/issue8269

Issue 8269 - The 'with statement' does not observe temporary object lifetime

--
1 2
Next ›   Last »