Taking the address of an rvalue struct

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Fri Jul 22 10:26:11 PDT 2011


On 7/22/11 12:10 PM, dsimcha wrote:
> == Quote from Andrei Alexandrescu (SeeWebsiteForEmail at erdani.org)'s article
>> This has long been a feature that I attempted to remove several times.
>
> What?  Taking the address of this?  Invoking methods on rvalue structs?

The latter.

>> It steps from the fact that you can invoke methods on rvalue structs.
>> Disallowing that would solve the issue, but would also eliminate a lot
>> of convenience.
>
> I think invoking methods on rvalue structs needs to be allowed come Hell or high
> water.  What's wrong with just banning any optimization of rvalue structs that
> have methods called on them, i.e. requiring the compiler to treat them the same as
> named methods, allocate stack space for them that doesn't get reused elsewhere in
> the same function, etc.?

Prolonging the lifetime of temporaries to the end of the enclosing 
function would be interesting, but perhaps surprising. Not to mention 
inefficient.


Andrei


More information about the Digitalmars-d mailing list