WTF did happen with struct constructor and ref in 2.061 ?

deadalnix deadalnix at gmail.com
Sun Jan 6 04:09:27 PST 2013


On Saturday, 5 January 2013 at 21:23:20 UTC, Sönke Ludwig wrote:
> Am 04.01.2013 20:35, schrieb deadalnix:
>> On Friday, 4 January 2013 at 19:15:03 UTC, Ali Çehreli wrote:
>>> > This may not have a storage :
>>> > foo(funcThatReturnsS());
>>>
>>> I don't see that. funcThatReturnsS returns an S, which must 
>>> have a storage as well.
>>>
>> 
>> This is where things are subtle. Depending on the calling 
>> convention, the struct may be returned
>> into a register. In such case it has no storage in memory.
>> 
>
> Although, nothing stops the compiler from initializing a struct 
> in a register either. At least when
> the constructor can be inlined.

In this case, this is a register promotion that happen as an 
optimization. This can happen to ANY variable, so I don't see how 
it is particularly relevant here. The important thing is that the 
struct HAVE a storage, and may be promoted in register as an 
optimization.


More information about the Digitalmars-d mailing list